Subscript indices must be real positive error
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to run a code(part of which is mentioned below) where h,u and x values have been defined separately in the rest of the code.. When I try to run this code to plot piecewise function, it gives me the following error "Subscript indices must either be real positive integers or logicals.
Error in fem51uapprox (line 78) y(c:d-1)=r.^2; %u(2*m-1,1).*w1+u(2*m,1).*w2+u(2*m+1,1).*w3;"
Can anybody please tell me what I am supposed to do to get rid of the error?
r=0:0.01:1;
y=zeros(length(x));
for m=1:n
w1=(1./h).*(r-x(2.*m)).*((2./h).*(r-x(2.*m))-1);
w2=(1-(2./h).*(r-x(2.*m))).*((2./h).*(r-x(2.*m))+1);
w3=(1./h).*(r-x(2.*m)).*((2./h).*(r-x(2.*m))+1);
c=round((m-1)*h*100);
d=round(m*h*100);
y(c:d-1)=r.^2; %u(2*m-1,1).*w1+u(2*m,1).*w2+u(2*m+1,1).*w3;
end
a=0:0.001:1;
b=(1-((1+a).^(3./2)))./3;
plot(r,y,a,b,'b');
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!