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.

답변 (2개)

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2019년 11월 25일

0 개 추천

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

Giuseppe Pintori
Giuseppe Pintori 2019년 11월 25일
I don't think I completely understood; what the vector you entered (a) should represent?
Also, how it should be the if?
if x(1,1) == 2 && x(1,N) == 20
a = ?
b = ?
c = ?
else
?
end

댓글을 달려면 로그인하십시오.

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2019년 11월 25일

0 개 추천

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

댓글 수: 1

Giuseppe Pintori
Giuseppe Pintori 2019년 11월 25일
The fact is that the code is actually more complicated than what I wrote initially because I wanted to understand the dynamic; furthermore, unfortunately, I cannot publish the code as it is part of a working paper by my supervisor.
My 3 scalars (a, b, c) are used to calculate variables that are contained in a parfor; all this leads to the creation of a 200x200 matrix from which a vector is derived which is the average of the simulations (200x1) and the initial and final value of that vector must be equal to two specific values. Initially I thought of using a fsolve but I can't understand how.
I know that the informations I provided are not many but without being able to publish the code I don't know how to do it.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2019년 11월 25일

댓글:

2019년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by