Create Plot based on calculated values
8 views (last 30 days)
Show older comments
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 Comments
dpb
on 25 May 2022
Edited: Walter Roberson
on 26 May 2022
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.
Answers (1)
Ravi
on 25 Sep 2023
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 Comments
See Also
Categories
Find more on Fit Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!