I have to store 3 sets of data, with for statement
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Devesh Kumar
il 21 Giu 2022
Commentato: Devesh Kumar
il 28 Giu 2022
for i = 1:cf_n
x1(i,1) = [2 Vr_on_cf Vr_R1_cf(i) Vr_R2_cf(i) Vr_cf_end]; % Az/D for cross - flow
y1(i,1) = [0 0.15 Az1_D(i) Az2_D(i) 0]; % reduced velocity
end
Here Vr_on_cf,Vr_cf_end is constant = 2.5 and 16 respectivetly , Vr_R1_cf & Vr_R2_cf are vector which contains 3 values say [ a b c] and [d e f], in this particular case cf_n is 3
now I want my output like this
x = [2 2.5 a d 16; 2 2.5 b e 16; 2 2.5 c f 16]; basically 5*3 matrix
how should I run the for loop
2 Commenti
Walter Roberson
il 21 Giu 2022
for i = 1:cf_n
x1(i,:) = [2 Vr_on_cf Vr_R1_cf(i) Vr_R2_cf(i) Vr_cf_end]; % Az/D for cross - flow
y1(i,:) = [0 0.15 Az1_D(i) Az2_D(i) 0]; % reduced velocity
end
Risposta accettata
Pooja Kumari
il 28 Giu 2022
Dear Devesh,
It is my understanding that you want to store three sets of data using for loop.
Given that Vr_on_cf, Vr_cf_end is constant = 2.5 and 16 respectively, Vr_R1_cf & Vr_R2_cf are vector which contains 3 values say [ a b c] and [d e f], in this particular case cf_n is 3.
You can get the provided output using the following code:
Vr_on_cf = 2.5;
Vr_cf_end = 16;
Vr_R1_cf = [ "a" "b" "c"];
Vr_R2_cf = [ "d" "e" "f"];
% x = [2 2.5 a d 16; 2 2.5 b e 16; 2 2.5 c f 16]; %Required Output
for i = 1:3
x1(i,:) = [2 Vr_on_cf Vr_R1_cf(i) Vr_R2_cf(i) Vr_cf_end] % instead of your provided code, you can use this changed to get the required output
end
Sincerely,
Pooja Kumari
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!