## Help, I don't understand why the output multiplies everything by 1.0e+03

### Antony Vu (view profile)

on 16 Nov 2019 at 5:27
Latest activity Commented on by Walter Roberson

### Walter Roberson (view profile)

on 16 Nov 2019 at 20:05

### James Tursa (view profile)

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

### James Tursa (view profile)

on 16 Nov 2019 at 5:38

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.

Antony Vu

### Antony Vu (view profile)

on 16 Nov 2019 at 19:59
Sorry, I am relatively new to matlab. Could you show what I could code so it does not multiply by e+03? I am trying to get the values [55, 0.1576, 9.568, 2450.1; 60, 0.1994, 7.671, 2456.6;]
Walter Roberson

### Walter Roberson (view profile)

on 16 Nov 2019 at 20:05
format long g
will cause it to not do that kind of multiplication.