Empty variables and vectors
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi guys, I need your help.
Is it possible to create three empty variables that fill up when a vector connected to the variables reaches a certain value?
I try to explain myself better; there are 3 variables (a, b, c) that affect the values contained within the vector x. What I would like to do is find those values such that the vector, in certain positions, assumes certain values; specifically I would need those 3 values of a, b, c such as to have x (1,1) equal to, for example, 2 and x (1, N) equal to 20.
Is it possible?
Thanks in advance for any help.
0 commentaires
Réponses (2)
Constantino Carlos Reyes-Aldasoro
le 25 Nov 2019
yes, it is easy
declare the variables as empty:
a =[]; b=[]; c = [];
then run the rest of the code and when you reach your condition (using an if) you can append on the variable
a= [a newValue];
2 commentaires
Constantino Carlos Reyes-Aldasoro
le 25 Nov 2019
I think we need a bit more information to fully understand each other, but let's see if this helps
you have three variables a,b,c on which a certain vector depends. Let's assume the range is 0 to 100, then try
a=0:100;
b=0:100;
c=0:100;
and the vector is a linear combination
v = 3*(a-20) - 2*b +0.7*c;
plot(v);grid on
and you want the value of a,b,c that make for example v = 25, Then, what you want is
>> a(v==25)
ans =
50
and the same for the other variables
Voir également
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!