can't use surf keep getting error
Mostrar comentarios más antiguos
I know that the equation below is extremely long but I would appreciate it if someone could assist me with figuring out why this won't work
EI = -1/(200e9*7.999e5);
f = @(x,y) EI.*((c(y./0.1,1).*((x.^3)./6))+(c(y./0.1,2).*(((x-5).^3)./6)).*(x>5)+(c(y./0.1,3).*(((x-10).^3)./6)).*(x>10)+(c(y./0.1,4).*(((x-15).^3)./6)).*(x>15)+(c(y./0.1,5).*(((x-20).^3)./6)).*(x>20)-16350.*((x-y).^3).*(x>y)+c(y./0.1,7).*x+c(y./0.1,8));
x = (0.1:0.1:25);
y = (0.1:0.1:25);
[X,Y] = meshgrid(x,y);
Z = f(X,Y);
surf(X,Y,Z)
I keep getting Subscript indices must either be real positive integers or logicals.
Also c is a predetermined matrix
Respuestas (1)
Star Strider
el 1 de Oct. de 2016
I cannot run your code because I do not have your ‘c’ matrix. My guess is that the problem is likely the way you are addressing it.
Try something like:
c(fix(y./0.1),1)
or:
c(ceil(y./0.1),1)
or something else to force an integer for the first subscript reference. The difference is that fix rounds toward 0 and ceil rounds toward +Inf.
Categorías
Más información sobre Surface and Mesh Plots 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!