Need some help on a MATLAB homework assignment.
3 views (last 30 days)
Show older comments
1. (30 pts) Table Only. Work problem 15.4 in the textbook. Additional requirements:
Write a MATLAB program (script or .m file).
Begin with the block of comments as described above. Add other comments throughout the program.
Use a range variable to assign the values in degrees C to a vector.
Use a formula on the vector above to create another vector in degrees F.
Combine the transpose of the two vectors to create a new vector (table).
Display the problem number and your name before displaying the table.
Display the table and include a table heading (with units).
No special formatting is required for this problem.
Print the script and the output table.
Extra credit: Use fprintf to use 3 digits after the decimal point for the values in degrees C and to use 2
digits after the decimal point for the values in degrees F.
This is the instructions^
Bellow is the code that i have so far but i cant make a table that had the names on the columns would love some help!
C=-50:10:150;
F=(C*(9/5))+32;
fprintf('HW #6 - Evan Melanson \n\n');
fprintf('Problem 1 \n\n');
oC=C';
oF=F';
fprintf('degree Celsius and Fahrenheit table\n');
oC=round(oC,3);
oF=round(oF,3);
plot(oC,oF)
xlabel('Celsius')
ylabel('Fahrenheit')
0 Comments
Answers (2)
Image Analyst
on 18 Nov 2021
I don't see the table() function being used anywhere. Didn't they say they wanted table variables only? Hint:
vectorC = (0:20:100); % A row vector.
vectorF = (9/5) * vectorC + 32;
% Combine transposes into table. Table needs column vectors.
t = table(vectorC', vectorF', 'VariableNames', {'C', 'F'})
To printf a number with 3 decimal places, use '%.3f':
fprintf('%.3f', yourNumber);
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!