Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

1 visualizzazione (ultimi 30 giorni)
.

Risposte (1)

Torsten
Torsten il 7 Dic 2022
Modificato: Torsten il 7 Dic 2022
k1=180; k2=50; k3=220;
knew=linspace(k1*0.4,k1*1.6,20);
m1=1.1; m2=3.4;
for i=1:length(knew)
K{i}=[knew(i)+k2,-k2;-k2,k2+k3];
M{i}=[m1,0;0,m2];
lambda{i}=eig(double(K{i}),double(M{i}));
omega_nf{i}=sqrt(lambda{i});
end
omega_nf{1:end}
ans = 2×1
8.0553 11.1997
ans = 2×1
8.1898 11.5578
ans = 2×1
8.2927 11.9257
ans = 2×1
8.3728 12.2973
ans = 2×1
8.4361 12.6686
ans = 2×1
8.4870 13.0371
ans = 2×1
8.5287 13.4012
ans = 2×1
8.5633 13.7599
ans = 2×1
8.5924 14.1128
ans = 2×1
8.6172 14.4595
ans = 2×1
8.6386 14.8002
ans = 2×1
8.6571 15.1347
ans = 2×1
8.6733 15.4633
ans = 2×1
8.6876 15.7861
ans = 2×1
8.7004 16.1032
ans = 2×1
8.7117 16.4149
ans = 2×1
8.7220 16.7215
ans = 2×1
8.7312 17.0229
ans = 2×1
8.7396 17.3196
ans = 2×1
8.7473 17.6116
  2 Commenti
Ayodimeji Ojelade
Ayodimeji Ojelade il 7 Dic 2022
Thank you! Do you know how I would be able to plot these on the x against k new on the y? I receive another error when I try due to the data format being a cell now?
Torsten
Torsten il 7 Dic 2022
Modificato: Torsten il 8 Dic 2022
k1=180; k2=50; k3=220;
knew=linspace(k1*0.4,k1*1.6,20);
m1=1.1; m2=3.4;
for i=1:length(knew)
K{i}=[knew(i)+k2,-k2;-k2,k2+k3];
M{i}=[m1,0;0,m2];
lambda{i}=eig(double(K{i}),double(M{i}));
omega_nf{i}=sqrt(lambda{i});
end
plot(cell2mat(omega_nf),knew)
grid on
If you don't need K, M and lambda in further calculations, you can also do
k1=180; k2=50; k3=220; n = 20;
knew=linspace(k1*0.4,k1*1.6,n);
m1=1.1; m2=3.4;
omega_nf = zeros(2,n);
for i=1:n
K=[knew(i)+k2,-k2;-k2,k2+k3];
M=[m1,0;0,m2];
lambda=eig(K,M);
omega_nf(:,i)=sqrt(lambda);
end
plot(omega_nf,knew)
grid on

Accedi per commentare.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by