matlab help: code ain't working, don't understand the error -
wrote following code, ain't working. error:
error: file: untitled1.m line: 7 column: 23 ()-indexing must appear last in index expression.
and script:
r=3; r1=7; r1=0:0.01:r; r2=r:0.01:r1; r3=r1:0.1:10; xvec=0:0.01:10; yvec(r1)=(r/(r1)^2).*(exp((r1)/r)((r1)^2-2*r(r1)+2*r^2)-2*r^2); yvec(r2)=(r^3/(r2)^2).*(e-2); yvec(r3)=0; figure(1); plot(xvec,yvec);
this think trying do:
r = 3; r1 = 7; xvec1 = 0:0.01:r; xvec2 = r:0.01:r1; xvec3 = r1:0.1:10; yvec1 = (r ./ xvec1.^2) .* (exp(xvec1/r) .* (xvec1.^2 - 2*r*xvec1 + 2*r^2) - 2*r^2); yvec2 = (r^3 ./ xvec2.^2) * (1e-2); yvec3 = zeros(size(xvec3)); figure(1); xvec = [xvec1 xvec2 xvec3]; yvec = [yvec1 yvec2 yvec3]; plot(xvec,yvec); like dustincarr wrote, should read basics section of matlab's documentation idea of how write expressions indices.
Comments
Post a Comment