필터 지우기
필터 지우기

How to generate a polar plot in a for loop

조회 수: 4 (최근 30일)
Chirag
Chirag 2023년 1월 11일
댓글: Chirag 2023년 1월 11일
Hello all,
I want to update a polar graph with every iteration in a for loop. I have tried different ways to solve it but it didn't workout. The funciton "Auto_test" works perfectly, but the only issue is I am not having any error in command window but the graph is not updating or not showing any lines in it.
function T = Auto_test(range, R, seconds) % R = resolution
times = range / R;
C = [times 4];
J = {'string','double','double','double'};
P = ["No.","Step_Size","Power","Freq"];
T = table('Size',C,'VariableTypes',J,'VariableNames',P);
figure
for step_times = 1:(times + 1)
Step_Size = (step_times - 1) * R;
MyArcus.PositionTo(Step_Size); % calling a motor rotation function
pause (seconds)
Power = str2double(app.obj.Get_Marker_Power(1)); % calling another funciton to get power
Freq = str2double(app.obj.Get_Marker_Freq(1)); % calling another funciton to get frequency
pause (1)
R_Step = deg2rad(Step_Size); % current motor angle converted to radian
polarplot(R_Step,Power); % polar plot
L = gca; % polar porperties
angles = 0:20:360;
L.ThetaTick = angles;
L.ThetaDir = 'clockwise';
L.RTickMode = 'auto';
L.ThetaZeroLocation = 'top';
hold on
% drawnow update % should I use ' hold on ' here?
T(step_times,:) = {step_times,Step_Size, Power, Freq}; % updating Table data
pause(0.5)
end
end
I will be thankful to your help.

채택된 답변

Adam Danz
Adam Danz 2023년 1월 11일
It looks like you are plotting single points. The default marker is 'none' such that the function produces lines without markers. But since you're providing only 1 point at a time, there is no line to plot.
Specify a marker if you want to plot a series of points.
% Replace this
polarplot(R_Step,Power)
% with this
polarplot(R_Step,Power, 'o')

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by