Three input statements in 'and function'
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm now using the code;
a(not(and(CLO < 1, ACT < 1))) = -4;
to make all other data of a where CLO and ACT are less then 1, -4. But I like to implement another boundery, but
a(not(and(CLO < 1, ACT >= 1, ACT <5))) = -4;
does not work. What is the correct form to execute this action?
ACT, CLO and a are [18x26] vectors.
0 Commenti
Risposte (2)
Roger Stafford
il 19 Feb 2017
It would either be:
a(~(CLO<1&ACT>=1&ACT<5)) = -4;
or if you were determined to use the ‘not’ and ‘and’ forms,
a(not(and(and(CLO<1,ACT>=1),ACT<5))) = -4;
0 Commenti
dpb
il 19 Feb 2017
Modificato: dpb
il 19 Feb 2017
Let's use operators instead of functions and associating parentheses to make easier to keep things straight..
I almost always start by writing the logical explicitly first...
ix=(CLO<1) & (ACT>=1 & ACT <5);
a(~ix) = -4;
I may then paste the expression into the addressing paren's but often will keep it for resulting simpler-to-read expression. The 'puter won't care, but my poor eyes do when start trying to debug or read code some time later...
You can, of course, always use the functional for and but it as you discovered is two inputs at a time so have to nest...
and(c,and(a,b))
etc., etc. which gets even more convoluted so the operators are a great simplifier here.
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!