How to generate a polar plot in a for loop
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!