フィルターのクリア

Hello, I get error "Unable to perform assignment because the left and right sides have a different number of elements". How to fix this?

1 回表示 (過去 30 日間)
K1= 10^-6;
K2=5*10^-6;
K3=10^-5;
delta=50;
Oa=10;
Pa=100;
Ko=0.1;
mu_1=10^-3;
gamma=75;
m1=10;
n=3;
K=0;
M=0;
h=0.5;
dt=0:h:100; %time scale
dtbaru=dt';
M1=zeros(length(dtbaru),1); %empty array for M1
M2=zeros(length(dtbaru),1); %empty array for M2
M3=zeros(length(dtbaru),1); %empty array for M3
Ki=zeros(length(n-1),1);
for j= 1:length(M1)
M1=1./(1+exp(dtbaru(j)+6)); %sigmoid equation
end
for i=1:length(Ki)
K(i+1)=K(i);
end
for j = 1:length(dtbaru)
M1(j) = M1(j)+dtbaru*[delta*M1(j)*[1-(M1(j)/gamma)]-2*K1*M1(j)*M1(j)-M1(j)*(K(i).*M(j))-(Oa-n)*K3*M1(j)*M3(j)-(Pa-Oa)*Ko*M1(j)*10-(mu_1*M1(j))];
end
Unable to perform assignment because the left and right sides have a different number of elements.

採用された回答

Walter Roberson
Walter Roberson 2023 年 5 月 7 日
dt=0:h:100; %time scale
Row vector
dtbaru=dt';
Column vector.
for j = 1:length(dtbaru)
M1(j) = M1(j)+dtbaru*[delta*M1(j)*[1-(M1(j)/gamma)]-2*K1*M1(j)*M1(j)-M1(j)*(K(i).*M(j))-(Oa-n)*K3*M1(j)*M3(j)-(Pa-Oa)*Ko*M1(j)*10-(mu_1*M1(j))];
The loop is iterating j over the length of dtbaru, but the assignment to M1(j) uses all of dtbaru in the calculation and so gives a column-vector result that is not going to fit into the single location M1(j)
Perhaps you wanted to use dtbaru(j) ?
  1 件のコメント
cindyawati cindyawati
cindyawati cindyawati 2023 年 5 月 8 日
If I want to use dtbaru(j) how the code?
I already use dtbaru(j) but cannot show the plot. How to fix it?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDirected Graphs についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by