Need some help on a MATLAB homework assignment.

6 vues (au cours des 30 derniers jours)
evan melanson
evan melanson le 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!
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')

Réponses (2)

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

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

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by