How to generate a polar plot in a for loop

5 ビュー (過去 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')
  1 件のコメント
Chirag
Chirag 2023 年 1 月 11 日
ohh =)) Thanks a lot @Adam Danz.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by