How to store function output as a matrix?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Wonderboy130
am 4 Sep. 2020
Kommentiert: Wonderboy130
am 4 Sep. 2020
Hi! I need help storing the output of P as a matrix so it would look like:
T P
0 corresponding value from P eqn
10 corresponding value from P eqn
20 corresponding value from P eqn
etc.
I am not the best with matlab, but any help would be appreciated. When I run the code, it becomes split apart. Thanks!
out = [];
for T = [0:10:100]
Volume = [0.0735560; 0.0736893; 0.0738233; 0.0739572; 0.0740910; 0.0742250; 0.0743592; 0.0744936; 0.0746282; 0.0747631; 0.0748981];
V0 = Volume(1,1); % index
V100 = Volume(11,1); % index
Temp = [0;10;20;30;40;50;60;70;80;90;100];
T0 = Temp(1,1); % index
T100 = Temp(11,1); % index
P = V0 + (((T - T0)*(V100 - V0))/(T100 - T0)); % simple equation
out = [T P]
end
0 Kommentare
Akzeptierte Antwort
KSSV
am 4 Sep. 2020
Bearbeitet: KSSV
am 4 Sep. 2020
out = zeros([],2);
count = 0 ;
for T = [0:10:100]
Volume = [0.0735560; 0.0736893; 0.0738233; 0.0739572; 0.0740910; 0.0742250; 0.0743592; 0.0744936; 0.0746282; 0.0747631; 0.0748981];
V0 = Volume(1,1); % index
V100 = Volume(11,1); % index
Temp = [0;10;20;30;40;50;60;70;80;90;100];
T0 = Temp(1,1); % index
T100 = Temp(11,1); % index
P = V0 + (((T - T0)*(V100 - V0))/(T100 - T0)); % simple equation
count = count+1 ;
out(count,:) = [T P]
end
OR
T = [0:10:100] ;
N = length(T) ;
out = zeros(1,N);
for i = 1:N
Volume = [0.0735560; 0.0736893; 0.0738233; 0.0739572; 0.0740910; 0.0742250; 0.0743592; 0.0744936; 0.0746282; 0.0747631; 0.0748981];
V0 = Volume(1,1); % index
V100 = Volume(11,1); % index
Temp = [0;10;20;30;40;50;60;70;80;90;100];
T0 = Temp(1,1); % index
T100 = Temp(11,1); % index
P = V0 + (((T(i) - T0)*(V100 - V0))/(T100 - T0)); % simple equation
count = count+1 ;
out(i) = P ;
end
[T' out']
Weitere Antworten (1)
David Hill
am 4 Sep. 2020
out = [];
for T = [0:10:100]
Volume = [0.0735560; 0.0736893; 0.0738233; 0.0739572; 0.0740910; 0.0742250; 0.0743592; 0.0744936; 0.0746282; 0.0747631; 0.0748981];
V0 = Volume(1,1); % index
V100 = Volume(11,1); % index
Temp = [0;10;20;30;40;50;60;70;80;90;100];
T0 = Temp(1,1); % index
T100 = Temp(11,1); % index
P = V0 + (((T - T0)*(V100 - V0))/(T100 - T0)); % simple equation
out = [out;T,P];
end
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!