Subscripted assignment dimension mismatch. Error in main (line 17) [y(:,6), a6] = curvepoly(x_heun,y_heun,6);
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
this worked for me fine yesterday, I haven't changed anything and today it says Subscripted assignment dimension mismatch.
Error in main (line 17)
[y(:,6), a6] = curvepoly(x_heun,y_heun,6);
Why? and how do I fix it?
fx = inline('(y - ((y.^2)./x)./x)','x','y');
x0 = 1;
xf = 5;
y0 = 1;
tol = 0.001;
N = [1:0.1:5];
for i = 1:length(N)
[y_heun, x_heun] = Heun(fx,x0,xf,y0,N(i),tol);
[y(:,2), a2] = curvepoly(x_heun,y_heun,2);
end
function [y,a] = curvepoly(x_heun,y_heun,order)
j = order;
for k = 1:j + 1;
for i = 1:j + 1;
A(k,i) = sum(x_heun.^((k+i-2)));
end
end
for i = 1:j + 1;
B(i,:) = sum(y_heun.*x_heun.^(i-1));
end
a = inv(A)*B;
y = 0;
for i = 1:j+1
y = y+a(i).*x_heun.^(i-1);
end
0 comentarios
Respuestas (1)
Matt J
el 26 de Abr. de 2013
The line in your error message does not appear in your code. I do see the rather similar line
[y(:,2), a2] = curvepoly(x_heun,y_heun,2);
which makes rather little sense within a loop over i, since it will just repeatedly overwrite y(:,2) and a2.
Perhaps that's what you changed.
1 comentario
Matt J
el 26 de Abr. de 2013
Aside from that, your function curvepoly returns a vector of length order+1. If size(y,1) does not match this, it would result in the error you've shown.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!