For Loop not plooting with "surf" command
5 views (last 30 days)
Show older comments
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)
0 Comments
Accepted Answer
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)
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!