Three input statements in 'and function'
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Roger Stafford
el 19 de Feb. de 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 comentarios
dpb
el 19 de Feb. de 2017
Editada: dpb
el 19 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!