Need some help on a MATLAB homework assignment.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Image Analyst
2021-11-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!