For Loop not plooting with "surf" command

조회 수: 5 (최근 30일)
Jose Moreno
Jose Moreno 2020년 3월 31일
댓글: Jose Moreno 2020년 3월 31일
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)

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by