Assignment between unlike types is not allowed. for loop
Mostrar comentarios más antiguos
Hello! I'm trying to solve a system of nonlinear equations,but my license doesn't support the fsolve function. The s1 is a parameter that takes values between 0 and 500, so i wanted to put that in a for loop and save the 3 values that i want(x=x1,s2=x2,D=x3) in arrays, in order to plot them.
m1=0.2;
m2=m1;
k1=15;
k2=25;
y1=0.4;
y2=0.3;
a1=0.05;
a2=5;
s1f=500;
s2f=600;
syms x1 x2 x3
eqns=[x3-(m1*s1)/(k1+s1+a2*x2)-(m2*x2)./(k2+x2+a1*s1)==0,x1-y1*(s1f-s1)+y2*(s2f-x2)==0,x3.*(s2f-x2)-((m2*x2)./(y2*(k2+x2+a1*s1))).*(y1*(s1f-s1)+y2*(s2f-x2))==0];
for s1=0:1:500
vars=[x1 x2 x3];
[sol1,sol2,sol3]=vpasolve(eqns,vars)
x(s1+1)=sol1;
s2(s1+1)=sol2;
D(s1+1)=sol3;
end
plot(x,D)
When i run the m.file i get:
roots2d
sol1 =
20.0
sol2 =
0
sol3 =
0
Assignment between unlike types is not allowed.
Error in roots2d (line 19)
x(s1+1)=sol1;
What am I missing here? Thank you in advance!
Respuesta aceptada
Más respuestas (1)
BHOLANATH KUMBHAKAR
el 9 de Sept. de 2019
syms x al lm mu;
lm=3;
mu=5;
n=round(10/.01);
al=0:0.01:10;
for i=1:n+1
f(i)=((mu-lm*x)^((lm/al(i))-1))/(1-x)
end
z(i)=int(f,0,.99999)
--------------------------------------------------------------------------------
Assignment between unlike types is not allowed.
Error in Untitled3 (line 7)
f(i)=((mu-lm*x)^((lm/al(i))-1))/(1-x)
why is it say????can anyone help me???
1 comentario
Walter Roberson
el 9 de Sept. de 2019
I suspect that you have an existing variable named f that is interfering.
z(i)=int(f,0,.99999)
Caution, that is after the for loop and tries to integrate all of entries in the vector f with respect to the default variable, and assign the result to the single location z(i)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!