필터 지우기
필터 지우기

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) ?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by