Need some help on a MATLAB homework assignment.

3 views (last 30 days)
evan melanson
evan melanson on 18 Nov 2021
Answered: Image Analyst on 18 Nov 2021
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!
fprintf('HW #6 - Evan Melanson \n\n');
fprintf('Problem 1 \n\n');
fprintf('degree Celsius and Fahrenheit table\n');

Answers (2)

David Hill
David Hill on 18 Nov 2021
Table=[C',F'];%array table

Image Analyst
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'})
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);



Community Treasure Hunt

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

Start Hunting!

Translated by