Create Plot based on calculated values
7 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
i think my problem isn't that hard but i cant figure out a perfect solution in Matlab App Designer.
I would like to shot my analysation in the GUI and therefore i created a diagramm.
Now i would like to show three different values over 3 different situations.
So for example Situation A / Situation B and Situation C on the X-Axis and the Values 80, 70 60 on the plot and the y Axis.
How can i manage this?
Thanks for your help!
4 个评论
dpb
2022-5-25
编辑:Walter Roberson
2022-5-26
Have you looked at/read syntax/examples of plot? Or is the Q? how to put a plot on/in the app? When you open the AppDesigner, there are several examples that contain plots not dissimilar from what you describe; begin with one of those and see how it's done there.
回答(1 个)
Ravi
2023-9-25
Hi Tim
Based on my understanding, it appears that you are facing a situation where you need to plot three different scenarios on the same set of axes. Allow me to propose a potential solution to address this matter.
To tackle this issue, please refer to the following code snippet where I have considered the following scenarios:
Situation A - a linear equation ();
Situation B - a quadratic equation (); and
Situation C - a cubic equation ().
Within the app, there is a "Generate" button that, when clicked, will display the desired plots.
The logic for plotting resides within the "Generate" button callback function that is “GenerateButtonPushed”. The linear equation, and the anonymous functions, ‘square’ and ‘cube’ can be modified to meet your requirements. In this example, I have considered the x-axis points to be integers from 1 to 5 inclusive.
% Button pushed function: GenerateButton
function GenerateButtonPushed(app, event)
x = 1:5;
square = @(x) x.*x;
cube = @(x) (x.*x).*x;
yA = x;
yB = square(x);
yC = cube(x);
plot(app.UIAxes, x, yA, x, yB, x, yC);
end
It is worth noting that all three scenarios can be plotted using a single plot function by passing the appropriate x-y pairs as arguments. Additionally, please keep in mind that the x-axis entries for each scenario can also be distinct if necessary.
Please refer to the following documentation for more insights and examples on plotting in AppDesigner.
Hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fit Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!