Help, I don't understand why the output multiplies everything by 1.0e+03
49 views (last 30 days)
Show older comments
Problem:
The first column of matrix steamTable indicates the temperature of water in Celsius. The remaining colums indicate the thermodynamic properties of water at the specified temperature. Assign selectedData with all rows of steamTable that correspond to temperatures greater than loTemp and less than hiTemp.
Ex: If loTemp is 54 and hiTemp is 64, then selectedData is [55, 0.1576, 9.568, 2450.1; 60, 0.1994, 7.671, 2456.6;].
%my code
function selectedData = GetSteamTableData( loTemp, hiTemp )
% SelectLogicalN: Return rows of the steam table data between input
% low and high temperatures..
% Inputs: loTemp, hiTemp - input low and high temperatures for
% indexing rows of steam table
%
% Outputs: selectedData - returned rows of steam table data
% between low and high temperatures
% steamTable: first column is temperature (Celsius)
steamTable = [ 50, 0.1235, 12.032, 2443.5;
55, 0.1576, 9.568, 2450.1;
60, 0.1994, 7.671, 2456.6;
65, 0.2503, 6.197, 2463.1; ];
% Assign tempData with first column of steamTable data
tempData = steamTable(:,1);
% Assign selectedTemps with logical column array of
% temperatures between loTemp and hiTeamp
selectedTemps = (tempData >= loTemp) & (tempData < hiTemp) ;
% Assign selectedData with specified rows of steamTable (Hint:
% use row-column indexing and the colon operator)
selectedData = steamTable(selectedTemps,:);
end
and for some reason it always outputs this. Where is the 1.0e+03 coming from?
ans =
1.0e+03 *
0.0550 0.0002 0.0096 2.4501
0.0600 0.0002 0.0077 2.4566
4 Comments
Accepted Answer
James Tursa
on 16 Nov 2019
That's just the default way that MATLAB displays the numbers, rather that tacking e+03 to each number individually. You could use the format statement to change this, or use the fprint function if you want a custom format.
2 Comments
More Answers (0)
See Also
Categories
Find more on Oil, Gas & Petrochemical 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!