Need some help on a MATLAB homework assignment.

1 回表示 (過去 30 日間)
evan melanson
evan melanson 2021 年 11 月 18 日
回答済み: Image Analyst 2021 年 11 月 18 日
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')

回答 (2 件)

David Hill
David Hill 2021 年 11 月 18 日
C=-50:10:150;
F=(C*(9/5))+32;
Table=[C',F'];%array table

Image Analyst
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'})
t = 6×2 table
C F ___ ___ 0 32 20 68 40 104 60 140 80 176 100 212
To printf a number with 3 decimal places, use '%.3f':
fprintf('%.3f', yourNumber);

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by