for loop values of certain output range
Afficher commentaires plus anciens
x=3;
for c= -2:1:2;
for q= -2:1:2;
g= (c*x)+q*(c+x);
h= g(all((g>= 5) & (g<=10)));
disp([ 'at c=', num2str(c), 'at q=', num2str(q), ',g=', num2str(h)])
end
end
this code giving me all the itertions of c, q and the values of h are empty for out of range values and showing the values within the range
but i just want the values of h within the range and their respective c&q only
I really need help on this one, time is a factor.
Réponse acceptée
Plus de réponses (1)
Andrei Bobrov
le 5 Sep 2019
x = 3;
c = -2:1:2;
q = -2:1:2;
g = c*x + q.*(c+x);
lo = g >= 5 & g <= 10;
out = table(c(lo),q(lo),g(lo),'Variablenames',{'c','q','g'});
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!