How to create a 180 degree polar plot in App designer using UI components from the menu
2 次查看(过去 30 天)
显示 更早的评论
I am trying to create a MATLAB application using MATLAB App Designer for my electroacoustics project.
GOAL:
Use HC-SR04 ultrasonic distance sensor, with Arduino UNO and MATLAB Support Package to create a system for visualizing distances.
HARDWARE:
Arduino UNO, HC-SR04 ultrasonic distance sensor and a servo motor ( SG90 or MG90S ).
SOFTWARE:
Only MATLAB App to communicate using USB port and display sensor data.
PROBLEMS:
I want to use a semicircular plot ( which I found out is called polar plot ). Polar plot enables me to plot distance with respect to the angle of the sensor ( corresponding to the angle of servo motor ). I want to use it in range from 0 to 180 degrees.
- App Designer component library offers only one similiar component which is Axes. This component doesn't allow for enough customization.
- I have managed to use the polar axis using the code bellow
This code does show the plot I need, and I used a slider to try and testout some values on the plot which causes the most irritating problem which is when calling polarplot my polaraxes's properties reset, meaning I lose my setting of ThetaLim to 0 - 180 deg.
The other thing is that creating components using code doesn't show them in APP LAYOUT which means push-pulling values to get them right. Using Panels helps here, but some flexibility in the tool would be greatly appreciated.
Please keep in my mind that I am a beginner and have used MATLAB App Designer successfully for my mechatronics project, but in it I had no need for modding the graphs.
-Thanks in forward
properties (Access = private)
PolarCoords % For my polaraxes
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
app.PolarCoords = polaraxes(app.Panel);
app.PolarCoords.ThetaLim = [0 180];
end
% Value changing function: Slider
function SliderValueChanging(app, event)
changingValue = event.Value;
polarplot(app.PolarCoords,changingValue);
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!