For Loop not plooting with "surf" command

19 visualizaciones (últimos 30 días)
Jose Moreno
Jose Moreno el 31 de Mzo. de 2020
Comentada: Jose Moreno el 31 de Mzo. de 2020
I am currently having an issue with getting a "surf" plot to be created. I am recieving an error message. Below i have attatched my code.
clc
Ma = zeros();
Pi = 0; Pinc = 10; Pf = 200; Xi = 0; Xinc = 1; Xf = 180;
for P = Pi:Pinc:Pf;
for X = Xi:Xinc:Xf;
F = (6000)/((sind(X)*33)-(cosd(X)*25));
j= P + 1;
x= X + 1;
Ma(j,x)= -6000+(P*sind(X)*33)-(P*cosd(X)*25);
end
end
[X,P]=meshgrid(Xi:Xinc:Xf,Pi:Pinc:Pf);
figure
surf(X,P,Ma)

Respuesta aceptada

Mehmed Saad
Mehmed Saad el 31 de Mzo. de 2020
Try this
clc
Ma = zeros();
Pi = 0; Pinc = 10; Pf = 200; Xi = 0; Xinc = 1; Xf = 180;
for P = Pi:Pinc:Pf;
for X = Xi:Xinc:Xf;
F = (6000)/((sind(X)*33)-(cosd(X)*25));
j= P/Pinc + 1; % changed this
x= X + 1;
Ma(j,x)= -6000+(P*sind(X)*33)-(P*cosd(X)*25);
end
end
[X,P]=meshgrid(Xi:Xinc:Xf,Pi:Pinc:Pf);
figure,surf(X,P,Ma)
  1 comentario
Jose Moreno
Jose Moreno el 31 de Mzo. de 2020
Thanks for the response. I see now that it was the equation for my counter that was wrong.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by