How do I plot sin(x), cos(x) and tan(x) when they are selected on the drop down for MATLAB app designer?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
August
il 2 Mag 2023
Risposto: Walter Roberson
il 2 Mag 2023
I am creating an app that will give you the derivative of the selected trig identity and then it will graph, of the three options, cos(x), sin(x), or tan(x), whichever one is chosen for the derivative. I currently have the app working to where when you click the equals button it give you the derivative of that chosen trig identity in the label but I want to connect the UI Axes to the button where when I hit equal on either cos(x), sin(x), or tan(x) it will show the graph of each trig identity. I am unsure on how to make this function work. I will attach my code view and design view below.


0 Commenti
Risposta accettata
Walter Roberson
il 2 Mag 2023
switch method
case 'Sinx'
result = 'Cosx';
fun = @cos;
case 'Cosx';
result = '-Sinx';
fun = @(x)-sin(x);
case 'Tanx';
result = 'Sec^2x';
fun = @(x) sec(x).^2;
and so on.
Then at some point in the function you need to create an x vector and apply fun() to the vector to get the values to plot.
I suggest you also consider the possibilities of using ItemsData https://www.mathworks.com/help/matlab/ref/uilistbox.html#buijl86-1_sep_shared-ItemsData -- it can save you having to use a switch or if/elseif
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!