How to generate a polar plot in a for loop

18 views (last 30 days)
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);
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
I will be thankful to your help.

Accepted Answer

Adam Danz
Adam Danz on 11 Jan 2023
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
% with this
polarplot(R_Step,Power, 'o')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by