For Loop not plooting with "surf" command

3 views (last 30 days)
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)

Accepted Answer

Mehmed Saad
Mehmed Saad on 31 Mar 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 Comment
Jose Moreno
Jose Moreno on 31 Mar 2020
Thanks for the response. I see now that it was the equation for my counter that was wrong.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!