Help with creating an array from two smaller arrays in a for loop
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi guys,
I am trying to create a 12x1 array (Fv) from two 1x6 arrays (Mx1 and Mx2). I want the 12x1 array to be populated by the Mx1 values for the first six rows, and the remaing rows to be populated by the Mx2 values. Here is the code I am using:
n = 12;
X1 = linspace(0,L/2,n/2);
X2 = linspace(L/2,L,n/2);
Mx1 = 25.*X1;
Mx2 = 25.*X2 - 50.*(X2-4);
Ft = ones(n,1)
for i = 1:size(Ft,1)
Fv(i) = Ft(i).*Mx1(i)
if i >= 6
Fv(i) = Ft(i).*Mx2(i)
end
end
I am getting the follwing errors
Fv =
0 20 40 60 80 0
Index exceeds the number of array elements. Index must not exceed 6.
Error in beam_deflection_bvp (line 52)
Fv(i) = Ft(i).*Mx1(i)
Can somebody help please?
0 Commenti
Risposta accettata
Voss
il 30 Ago 2023
L = 8;
n = 12;
X1 = linspace(0,L/2,n/2);
X2 = linspace(L/2,L,n/2);
Mx1 = 25.*X1;
Mx2 = 25.*X2 - 50.*(X2-4);
Fv = [Mx1 Mx2].'
3 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices 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!