How to generate a polar plot in a for loop
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
Adam Danz
il 11 Gen 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
polarplot(R_Step,Power)
% with this
polarplot(R_Step,Power, 'o')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Graphics Performance in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!