Why is my table getting all the same values when it shouldn’t?
For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be:For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be: For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be: simulink, table, while loop MATLAB Answers — New Questions