What should be the coding for the problem mentioned?

Hi,
I have an input y whose value keeps changing for different iteration and y is being fed to two parameters namely r and R. Now I'm trying to get a piece of coding doing which, when the value of y changes, values of r and R must also change. Please help me.

回答 (1 件)

Image Analyst
Image Analyst 2014 年 5 月 21 日

0 投票

Something like this
for k = 1 : 10
y = rand(1); % Or however you get y to change
r(k) = Function1(y);
R(k) = Function2(y);
end
We don't know how r and R change with y so you'll have to write those functions.

10 件のコメント

Priya
Priya 2014 年 5 月 21 日
編集済み: Priya 2014 年 5 月 21 日
Thanks very much. But I have got some queries in your answer. Firstly, what is 1 in the line below.
y = rand(1);
How is k defined? Also could you please tell me what are those functions, I mean what should they be like?
Mahdi
Mahdi 2014 年 5 月 21 日
It's just a random value that he's using since you didn't specify what y is. Basically, just change y to what you want it to be.
Priya
Priya 2014 年 5 月 21 日
編集済み: Priya 2014 年 5 月 21 日
Thanks. Perhaps,I have programmed in such a way that y value is chosen automatically . I don't change the value of y everytime. Is there any function that accepts y and returns a value for r accordingly?
Image Analyst
Image Analyst 2014 年 5 月 21 日
Just create y however you do it. Pull it out of the loop if what you said first ("input y whose value keeps changing for different iteration") is not true and y does not change at every iteration of a loop.
Then send it into some function that changes r and R based on y. You haven't said the formula for calculating r and R from y, but whatever it is, just use it.
Image Analyst
Image Analyst 2014 年 5 月 21 日
R_1 does not appear to depend on y_w. But if something else changes in the formula for R_1, you can always execute that line for R_1 again.
Priya
Priya 2014 年 5 月 21 日
編集済み: Priya 2014 年 5 月 21 日
Is it necessary for R_1 to depend on y_w, so that it can be changed.All these time I have been looking for a command that allows me to do this. Please give me some idea.
Image Analyst
Image Analyst 2014 年 5 月 21 日
You asked "Is it necessary for R_1 to depend on y_w" - well there's no way for me to know that. All I know is that it doesn't depend on it in the way that you've written the formula now.
Image Analyst
Image Analyst 2014 年 5 月 21 日
I can't read that file. Is it a Simulink model? I don't have Simulink.
Image Analyst
Image Analyst 2014 年 5 月 22 日
Like I said, I don't have Simulink so this is nothing I can help you with. Hopefully someone else will answer. You didn't add the Simulink product to the Products list so you might have already lost some potential answerers. I'll add it for you.
Priya
Priya 2014 年 5 月 22 日
Thank you.

この質問は閉じられています。

製品

タグ

質問済み:

2014 年 5 月 21 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by