table is not working correctly
3 views (last 30 days)
Show older comments
C1=input('Enter starting temperature im Celsius...')
dC=input('Enter temperature increment in Celsius...')
C=[C1:dC:((C1+dC)*25)]
R=C_to_R(C)
C_to_R_table=[C',R']
disp('Celsius to Rankine conversion table')
disp('Celsius Rankine')
fprintf(' %6.3f %9.3f \n',C_to_R_table)
function [ R ] = C_to_R( C )
%Temperature in Celsius to Rankine
R = 9/5*C+491.67;
C_to_R_table =
0 491.6700
10.0000 509.6700
20.0000 527.6700
30.0000 545.6700
40.0000 563.6700
50.0000 581.6700
60.0000 599.6700
70.0000 617.6700
80.0000 635.6700
90.0000 653.6700
100.0000 671.6700
110.0000 689.6700
120.0000 707.6700
130.0000 725.6700
140.0000 743.6700
150.0000 761.6700
160.0000 779.6700
170.0000 797.6700
180.0000 815.6700
190.0000 833.6700
200.0000 851.6700
210.0000 869.6700
220.0000 887.6700
230.0000 905.6700
240.0000 923.6700
250.0000 941.6700
So i made a function file to convert temp in celsius to rankine and the initial table works fine however when i do fprintf the values for both columns differ from the correct ones
1 Comment
Star Strider
on 27 Nov 2016
I don’t see the problem.
A 10°C increment should be equivalent to an 18°R (or 18°F) increment, and that looks to me to be displaying the correct result.
Answers (1)
Walter Roberson
on 27 Nov 2016
fprintf(' %6.3f %9.3f \n', C_to_R_table.' ); %the transpose is important
fprintf() proceeds down the columns of whatever data is passed to it, which is consistent with MATLAB array indexing but is confusing when you are working with column output.
0 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!