How to store function output as a matrix?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
KSSV
il 4 Set 2020
Modificato: KSSV
il 4 Set 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']
Più risposte (1)
David Hill
il 4 Set 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
Vedere anche
Categorie
Scopri di più su Image Processing Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!