Error in plotting - indices not compatible
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have the following code -
syms y t g
f1 = -2*g*(t.^3 +t.^2)/((1 - y).^(1-2*g)) + 2*g*(3-t)*(3 - t.^2)^2./(((2 - t).^2).*y.^(1-2*g)) + (8*g*(t+1))./(y.^(1- 2*g)) - 2*g*(3-t)*(3 - 2*t).^2./(((2 - t).^2).*(1 - y).^(1-2*g));
[N1,D1] = numden(f1);
f2 = t - (((y.^(2*g))*(2/3) - (((1-y).^(2*g)).*((3 - 2*t)./(3*(2-t)))))./((y.^(2*g)).*(((3-t.^2))./(3*(2-t))) - ((1-y).^(2*g)).*(t/3)));
[N2,D2] = numden(f2);
tsol = solve(N2==0,t,'MaxDegree',3);
N1_subs_tsol1 = subs(N1,t,tsol(1));
N1_subs_tsol2 = subs(N1,t,tsol(2));
N1_subs_tsol3 = subs(N1,t,tsol(3));
G = 0.01:0.001:0.12;
soly1(1) = vpasolve(subs(N1_subs_tsol1/(y*(1-y)^(2*g)),g,G(1))==0,y);
soly2(1) = vpasolve(subs(N1_subs_tsol2/y/(-2*g),g,G(1))==0,y);
soly3(1) = vpasolve(subs(N1_subs_tsol3/y/(-2*g),g,G(1))==0,y);
for i = 2:numel(G)
soly1(i) = vpasolve(subs(N1_subs_tsol1/(y*(1-y)^(2*g)),g,G(i))==0,y,soly1(i-1));
soly2(i) = vpasolve(subs(N1_subs_tsol2/y/(-2*g),g,G(i))==0,y,soly2(i-1));
soly3(i) = vpasolve(subs(N1_subs_tsol3/y/(-2*g),g,G(i))==0,y,soly3(i-1));
end
solt1 = arrayfun(@(soly1,G)subs(tsol(1),[y,g],[soly1,G]),soly1,G);
solt2 = arrayfun(@(soly2,G)subs(tsol(2),[y,g],[soly2,G]),soly2,G);
solt3 = arrayfun(@(soly3,G)subs(tsol(3),[y,g],[soly3,G]),soly3,G);
hold on
p1 = plot(G,soly1,'r');
%plot(G,solt1,'r')
p2 = plot(G,soly2,'b');
%plot(G,solt2,'b')
p3 = plot(G,1./(1+(1/3).^(1./(1-2*G))),'g');
legend([p1,p2,p3],[" Slice 1","Slice 2","Slice 3"])
xlabel("g")
hold off
grid on
Why I am getting the following error -
Unable to perform assignment because the
indices on the left side are not compatible
with the size of the right side.
Error in sym/privsubsasgn (line 1200)
L_tilde2 = builtin('subsasgn',L_tilde,struct('type','()','subs',{varargin}),R_tilde);
Error in indexing (line 1031)
C = privsubsasgn(L,R,inds{:});
Please help @Torsten
0 Commenti
Vedere anche
Categorie
Scopri di più su Calculus 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!