Create Plot based on calculated values

7 vues (au cours des 30 derniers jours)
Tim
Tim le 25 Mai 2022
Réponse apportée : Ravi le 25 Sep 2023
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 commentaires
Walter Roberson
Walter Roberson le 25 Mai 2022
categorical() for the x values, maybe for the y as well
dpb
dpb le 25 Mai 2022
Modifié(e) : Walter Roberson le 26 Mai 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.

Connectez-vous pour commenter.

Réponses (1)

Ravi
Ravi le 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.

Catégories

En savoir plus sur Fit Postprocessing dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by