Selecting steam table data using relational operators. The first column of matri
ID: 3587953 • Letter: S
Question
Selecting steam table data using relational operators.
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;].
Your Function:
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; % FIXME
% Assign selectedTemps with logical column array of
% temperatures between loTemp and hiTeamp
selectedTemps = [ true; true; true; true; ]; % FIXME
% Assign selectedData with specified rows of steamTable (Hint:
% use row-column indexing and the colon operator)
selectedData = steamTable; % FIXME
end
Code to call your function:
GetSteamTableData(54, 64)
Explanation / Answer
CODE
GetStramTableData.m
function selectedData = GetStramTableData(loTemp,hiTemp)
% Help commants here
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; ]; % The steam table as given
% Assign tempData with first colum of steamTable data
tempData = steamTable(:,1);
% Assign selectedTemps with logical column array of
% temperature between lotemp and hiTemp
selectedTemps = (tempData>loTemp) & (tempData<hiTemp);
% Assign selectedData with specified rows of steamTable
selectedData = steamTable(selectedTemps.*[1:4]'~=0,:);
end
OUTPUT
>> GetStramTableData(54,64)
ans =
1.0e+03 *
0.0550 0.0002 0.0096 2.4501
0.0600 0.0002 0.0077 2.4566
IF ANY QUERIES REGARDING CODE PLEASE GET BACK TO ME
HOPE IT MAY HELP YOU
THANK YOU
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.