logical array variables in a loop

2 vues (au cours des 30 derniers jours)
Peter P
Peter P le 17 Sep 2019
Modifié(e) : madhan ravi le 17 Sep 2019
I have variables 'filter_X' that include only logical arrays:
filter_p = outlier & incl_p;
filter_r = outlier & incl_r;
filter_p_r = outlier & incl_p_r;
now I want to plot (seperated plots) all three examples below with a loop.
plot(A(filter_p), B(filter_p), 'ro')
plot(A(filter_r), B(filter_r), 'ro')
plot(A(filter_p_r), B(filter_p_r), 'ro')
Any suggestions? Thanks in advance!

Réponse acceptée

madhan ravi
madhan ravi le 17 Sep 2019
Modifié(e) : madhan ravi le 17 Sep 2019
It would been simpler if they were stored in a cell array:
c{1} = outlier & incl_p;
c{2}= outlier & incl_r;
c{3} = outlier & incl_p_r;
Note: Naming variables is a bad idea ( https://in.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval ). Loop through c to get three different figures with a figure call.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by