Question

MATLAB question: I have written a code to solve for a metals resitance. Here is the...

MATLAB question: I have written a code to solve for a metals resitance. Here is the problem statement:

Part 1 (Algorithms) – due Friday:

Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves as described above (given several arrays of information, calculates the resistance of each metal in the arrays). If given the correct information, the algorithm should be able to calculate the resistance of ANY metal that you have provided information for in the arrays.

Consider that you will be provided multiple arrays that contain the information for each of the relevant properties. For example, you might have 4 arrays that look like so:

metal_names

silicon

copper

aluminum

gold

germanium

metal_resistivities

.0023

. 000000017

.0000000282

.0000000244

.46

wire_length_in_meters

1

5

25

50

85

wire_diam_in_mm

1

2

3

4

5

The following link will take you to a page that displays some metal resistivity levels at 20 degrees Celsius. http://www.cleanroom.byu.edu/Resistivities.phtml

You might want to read part 2, to get a clearer idea of how your instructions should look.

Write your instructions (algorithm) in a separate word document. This part is due on Friday. When you have completed writing your algorithm, submit the word document to canvas as your assignment submission.

Part 2 (Implementation) – due next friday:

Follow your instructions (the algorithm you wrote) and write a script in Matlab that can read in information from 4 separate arrays and calculate the resistance for all the metals in the arrays. You can use the arrays above as sample input if you’d like. Be sure to name them THE SAME AS THEY’RE NAMED ABOVE. The function should calculate the resistance of all the metals in the arrays using the formula above, and should output the result to the command window.

If necessary, rewrite your instructions (your algorithm) if you realize that you may have possibly described your instructions in such a way that they cannot be easily implemented in Matlab. If you rewrite your instructions, you MUST include them again with your code submission. This part is due the following Friday.

When you have finished writing your script, be sure to test it to make sure that it works. You may want to use the values I provided above, calculate it by hand, then compare it with what your script outputs.

When you have completed writing your scrip, submit your .m file on canvas as your submission. If you had to rewrite your algorithm, you must also provide the new algorithm. In this case, you should zip up BOTH the algorithm (word document) AND the script (.m file) and submit just a single zip file.

NOTE: The metal names array “metal_names” is going to be a cell array. As far as this assignment is concerned, the ONLY difference for you will be that you MUST use curly brackets { } instead of square brackets [ ] to create it (if you want to test your own code, that is). Other than that you can use it EXACTLY THE SAME WAY as you would use a regular array for this assignment.

For example, the following arrays:   

test_array = { ‘one string’, ‘another string’ }   ß Cell array of strings

numeric_array = [ 10 20 ]               ß numeric array of doubles

are just 1 x 2 arrays. The first is a cell array of strings, the second is a regular array of numbers. You would reference the elements EXACTLY THE SAME WAY that you would reference a regular array’s contents. So:

test_array(1)    ß This would display:   ‘one string’

numeric_array(1) ß This would display: 10

Part 1 (Algorithms) – due Friday:

Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves as described above (given several arrays of information, calculates the resistance of each metal in the arrays). If given the correct information, the algorithm should be able to calculate the resistance of ANY metal that you have provided information for in the arrays.

Consider that you will be provided multiple arrays that contain the information for each of the relevant properties. For example, you might have 4 arrays that look like so:

metal_names

silicon

copper

aluminum

gold

germanium

metal_resistivities

.0023

. 000000017

.0000000282

.0000000244

.46

wire_length_in_meters

1

5

25

50

85

wire_diam_in_mm

1

2

3

4

5

The following link will take you to a page that displays some metal resistivity levels at 20 degrees Celsius. http://www.cleanroom.byu.edu/Resistivities.phtml

You might want to read part 2, to get a clearer idea of how your instructions should look.

Write your instructions (algorithm) in a separate word document. This part is due on Friday. When you have completed writing your algorithm, submit the word document to canvas as your assignment submission.

Part 2 (Implementation) – due next friday:

Follow your instructions (the algorithm you wrote) and write a script in Matlab that can read in information from 4 separate arrays and calculate the resistance for all the metals in the arrays. You can use the arrays above as sample input if you’d like. Be sure to name them THE SAME AS THEY’RE NAMED ABOVE. The function should calculate the resistance of all the metals in the arrays using the formula above, and should output the result to the command window.

If necessary, rewrite your instructions (your algorithm) if you realize that you may have possibly described your instructions in such a way that they cannot be easily implemented in Matlab. If you rewrite your instructions, you MUST include them again with your code submission. This part is due the following Friday.

When you have finished writing your script, be sure to test it to make sure that it works. You may want to use the values I provided above, calculate it by hand, then compare it with what your script outputs.

When you have completed writing your scrip, submit your .m file on canvas as your submission. If you had to rewrite your algorithm, you must also provide the new algorithm. In this case, you should zip up BOTH the algorithm (word document) AND the script (.m file) and submit just a single zip file.

NOTE: The metal names array “metal_names” is going to be a cell array. As far as this assignment is concerned, the ONLY difference for you will be that you MUST use curly brackets { } instead of square brackets [ ] to create it (if you want to test your own code, that is). Other than that you can use it EXACTLY THE SAME WAY as you would use a regular array for this assignment.

For example, the following arrays:   

test_array = { ‘one string’, ‘another string’ }   ß Cell array of strings

numeric_array = [ 10 20 ]               ß numeric array of doubles

are just 1 x 2 arrays. The first is a cell array of strings, the second is a regular array of numbers. You would reference the elements EXACTLY THE SAME WAY that you would reference a regular array’s contents. So:

test_array(1)    ß This would display:   ‘one string’

numeric_array(1) ß This would display: 10

Part 1 (Algorithms) – due Friday:

Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves as described above (given several arrays of information, calculates the resistance of each metal in the arrays). If given the correct information, the algorithm should be able to calculate the resistance of ANY metal that you have provided information for in the arrays.

Consider that you will be provided multiple arrays that contain the information for each of the relevant properties. For example, you might have 4 arrays that look like so:

metal_names

silicon

copper

aluminum

gold

germanium

metal_resistivities

.0023

. 000000017

.0000000282

.0000000244

.46

wire_length_in_meters

1

5

25

50

85

wire_diam_in_mm

1

2

3

4

5

The following link will take you to a page that displays some metal resistivity levels at 20 degrees Celsius. http://www.cleanroom.byu.edu/Resistivities.phtml

You might want to read part 2, to get a clearer idea of how your instructions should look.

Write your instructions (algorithm) in a separate word document. This part is due on Friday. When you have completed writing your algorithm, submit the word document to canvas as your assignment submission.

Part 2 (Implementation) – due next friday:

Follow your instructions (the algorithm you wrote) and write a script in Matlab that can read in information from 4 separate arrays and calculate the resistance for all the metals in the arrays. You can use the arrays above as sample input if you’d like. Be sure to name them THE SAME AS THEY’RE NAMED ABOVE. The function should calculate the resistance of all the metals in the arrays using the formula above, and should output the result to the command window.

If necessary, rewrite your instructions (your algorithm) if you realize that you may have possibly described your instructions in such a way that they cannot be easily implemented in Matlab. If you rewrite your instructions, you MUST include them again with your code submission. This part is due the following Friday.

When you have finished writing your script, be sure to test it to make sure that it works. You may want to use the values I provided above, calculate it by hand, then compare it with what your script outputs.

When you have completed writing your scrip, submit your .m file on canvas as your submission. If you had to rewrite your algorithm, you must also provide the new algorithm. In this case, you should zip up BOTH the algorithm (word document) AND the script (.m file) and submit just a single zip file.

NOTE: The metal names array “metal_names” is going to be a cell array. As far as this assignment is concerned, the ONLY difference for you will be that you MUST use curly brackets { } instead of square brackets [ ] to create it (if you want to test your own code, that is). Other than that you can use it EXACTLY THE SAME WAY as you would use a regular array for this assignment.

For example, the following arrays:   

test_array = { ‘one string’, ‘another string’ }   ß Cell array of strings

numeric_array = [ 10 20 ]               ß numeric array of doubles

are just 1 x 2 arrays. The first is a cell array of strings, the second is a regular array of numbers. You would reference the elements EXACTLY THE SAME WAY that you would reference a regular array’s contents. So:

test_array(1)    ß This would display:   ‘one string’

numeric_array(1) ß This would display: 10

Part 1 (Algorithms) – due Friday:

Think about how you might solve the problem of calculating the resistance of a given group of metals depending on the type of metal, the length of the wire and the area of the wire (if given the diameter only – so you must calculate the area). Write instructions (an algorithm) for a script that behaves as described above (given several arrays of information, calculates the resistance of each metal in the arrays). If given the correct information, the algorithm should be able to calculate the resistance of ANY metal that you have provided information for in the arrays.

Consider that you will be provided multiple arrays that contain the information for each of the relevant properties. For example, you might have 4 arrays that look like so:

metal_names

silicon

copper

aluminum

gold

germanium

metal_resistivities

.0023

. 000000017

.0000000282

.0000000244

.46

wire_length_in_meters

1

5

25

50

85

wire_diam_in_mm

1

2

3

4

5

The following link will take you to a page that displays some metal resistivity levels at 20 degrees Celsius. http://www.cleanroom.byu.edu/Resistivities.phtml

You might want to read part 2, to get a clearer idea of how your instructions should look.

Write your instructions (algorithm) in a separate word document. This part is due on Friday. When you have completed writing your algorithm, submit the word document to canvas as your assignment submission.

Part 2 (Implementation) – due next friday:

Follow your instructions (the algorithm you wrote) and write a script in Matlab that can read in information from 4 separate arrays and calculate the resistance for all the metals in the arrays. You can use the arrays above as sample input if you’d like. Be sure to name them THE SAME AS THEY’RE NAMED ABOVE. The function should calculate the resistance of all the metals in the arrays using the formula above, and should output the result to the command window.

If necessary, rewrite your instructions (your algorithm) if you realize that you may have possibly described your instructions in such a way that they cannot be easily implemented in Matlab. If you rewrite your instructions, you MUST include them again with your code submission. This part is due the following Friday.

When you have finished writing your script, be sure to test it to make sure that it works. You may want to use the values I provided above, calculate it by hand, then compare it with what your script outputs.

When you have completed writing your scrip, submit your .m file on canvas as your submission. If you had to rewrite your algorithm, you must also provide the new algorithm. In this case, you should zip up BOTH the algorithm (word document) AND the script (.m file) and submit just a single zip file.

NOTE: The metal names array “metal_names” is going to be a cell array. As far as this assignment is concerned, the ONLY difference for you will be that you MUST use curly brackets { } instead of square brackets [ ] to create it (if you want to test your own code, that is). Other than that you can use it EXACTLY THE SAME WAY as you would use a regular array for this assignment.

For example, the following arrays:   

test_array = { ‘one string’, ‘another string’ }   ß Cell array of strings

numeric_array = [ 10 20 ]               ß numeric array of doubles

are just 1 x 2 arrays. The first is a cell array of strings, the second is a regular array of numbers. You would reference the elements EXACTLY THE SAME WAY that you would reference a regular array’s contents. So:

test_array(1)    ß This would display:   ‘one string’

numeric_array(1) ß This would display: 10

Here is my code:

Array_mn = {'Silicon', 'Copper', 'Aluminum', 'Gold', 'Germanium'};

Array_mr = [.0023, .000000017, .0000000282, .0000000244, .46];

Array_l = [1, 5, 25, 50, 85];

Array_d = [1:5];

size = size(Array_mn);

% resistances (array of numbers with size elements)

for i = 1:size

resistances(i) = Array_mr(i)*Array_l/(pi*(Array_d(i)/2)^2);

end

for i = 1:size

print "Resitance of metal" + Array_mn(i) + ":is" + Array_mr(i)

end

Matlab will not accept this and cannot figure out why. Please Help!

0 0
Add a comment Improve this question Transcribed image text
Answer #1


clc
Array_mn = {'Silicon', 'Copper', 'Aluminum', 'Gold', 'Germanium'};
Array_mr = [.0023, .000000017, .0000000282, .0000000244, .46];
Array_l = [1, 5, 25, 50, 85];
Array_d = 1:5;
Size = size(Array_mn,2);%%size returns [row ,column].Giving as argument will return only column
% resistances (array of numbers with size elements)
for i = 1:Size
resistances(i) = Array_mr(i)*Array_l(i)/(pi*(Array_d(i)/2)^2);
end
for i = 1:Size
fprintf( 'Resitance of metal %s :is %f\n',Array_mn{i},resistances(i))%print is not a command for dispaying output, fprintf will be used
end

Command Window Resitance of metal Silicon :is 0.002928 Resitance of metal Copper is 0.000000 Res Resitance of metal Gold :is

Add a comment
Know the answer?
Add Answer to:
MATLAB question: I have written a code to solve for a metals resitance. Here is the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Require a written script for the presentation Require only a written script for the video 3....

    Require a written script for the presentation Require only a written script for the video 3. LMN Pty Ltd is a new company with an interesting new service that shows great potential. However, the company needs more long-term finance to grow. Its founder, Harpreet, is an expert in her area but she knows very little about business. She is currently the only shareholder of the company and has no family or friends that could provide further financing. You have been...

  • I just need an algorithm for this please! I have C++ code for it but I dont know how to creat an ...

    I just need an algorithm for this please! I have C++ code for it but I dont know how to creat an algorithm .. CSE 1311-Project 4 Part I: Create and print out the two arrays: (Be sure to do this first) You are allowed to hard code these arrays into your program. You can also put the data into a file and read the information into the program. The data is as follows: 150 250 Anne Bob Ralph 305...

  • Project 2 Sorting, CPU Time, and Big O Analysis Note: you will be using Microsoft Visual...

    Project 2 Sorting, CPU Time, and Big O Analysis Note: you will be using Microsoft Visual Studios 2019 as the compiler. This is an individual assignment. You will have lab time to work on this assignment as well as homework time. Each person will analyze two sorts. The first sort will be either bubble sort or insertion sort. The second sort will be either quick sort or merge sort. Create two projects, one for each sort in the given choices....

  • Hi, I need help with my comp sci assignment. The parameters are listed below, but I...

    Hi, I need help with my comp sci assignment. The parameters are listed below, but I am having trouble generating the number of occurrences of each word. Please use a standard library. Read in the clean text you generated in part 2 (start a new cpp file). Create a list of all the unique words found in the entire text file (use cleanedTextTest.txt for testing). Your list should be in the form of an array of structs, where each struct...

  • using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last in...

    using matlab In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...

  • Can someone solve number 5 using Matlab? In Class Exercises 8-Arrays For the following exercises, assume...

    Can someone solve number 5 using Matlab? In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1....

  • can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient...

    can u please on matlab, i have the solution on paper. [30pts] Write a robust, efficient MATLAB script to find the eigenvalues and eigenvectors of a 2 x2 matrix input by the user. You should test out your script using the following matrices. 1::)-::) 3 2 3 1 B. 1 2 C 2 3 A- D- 4 1 2 4 4 8 -3 8 You may not use any special MATLAB tools. Instead, work symbolically and derive general expressions for...

  • How would i code this in MatLab 3. Write the program, openclasses.m, where you start by...

    How would i code this in MatLab 3. Write the program, openclasses.m, where you start by creating a structured array called class which contains the information in the following table (note: seats should be a single fieldname with a (1x2) array inside it). Class Title Introduction to Engineering Computers in Psychology Writing and Rhetoric Beginning Spanish Introduction to Africana Studies Number Seats (Max, Enrolled) 10111 (45, 32) 20000 (28, 25) 12100 (14, 14) 10101 (19,13) (36, 32) 20082 From this...

  • Can you help me make these two methods listed below work? I have code written but...

    Can you help me make these two methods listed below work? I have code written but it is not working. I would appreciate any advice or help. Function "isAPalidrome" accepts an array of characters and returns an integer. You must use pointer operations only, no arrays. This function should return 1 (true) if the parameter 'string' is a palindrome, or 0 (false) if 'string' is not a palindrome. A palindrome is a sequence of characters which when reversed, is the...

  • This is an assignment for my algorithm class which I have written the code partially and...

    This is an assignment for my algorithm class which I have written the code partially and only need to complete it by adding a time function that calculates the average running time. We could use any programming language we want so I am using C++. I am including the instruction and my partial code below. Thank you! Implement linearSearch(a,key) and binarySearch( a,key)functions. Part A.In this part we will calculate theaverage-case running time of each function.1.Request the user to enter a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT