How to change two variables in one loop?

6 views (last 30 days)
Ani Asoyan
Ani Asoyan on 13 Jul 2020
Commented: Ani Asoyan on 14 Jul 2020
Hi... I have something like this..
for i=1:5
/some code/
p and N are parameters,, and I want to change a and d variables in this loop simultaneously.. how can I do that? Thank you .

Answers (1)

the cyclist
the cyclist on 13 Jul 2020
Edited: the cyclist on 13 Jul 2020
There are many things about your question that I don't fully understand. The least important is whether you meant the loop to go over k rather than i. If not, then I don't understand how i is supposed to be used.
Most importantly, I don't really understand what you mean by "simultaneously" here. Do you mean that you want to somehow execute
in a single line of code?
Why? These two lines of code do not affect each, and could be executed in either order, with same result.
You could define a function that returns a and d "simultaeously", but I'm not sure of the point of that.
Maybe I just don't fully understand your question.
Ani Asoyan
Ani Asoyan on 14 Jul 2020
yeah sorry because there's a function called u_p ,,,here's its code
function u=u_p(x,x_e,N,d)
u = -(x-x_e).^2+N.*d;

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!