Help, I don't understand why the output multiplies everything by 1.0e+03
55 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
James Tursa
2019-11-16
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Oil, Gas & Petrochemical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!