Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Concerning the loop functions

Subject: Concerning the loop functions

From: Amr Sadek

Date: 7 Jun, 2014 05:45:12

Message: 1 of 2

Hello,
How can I use the final results obtained from the first iteration of the loop in the second iteration of the same loop?
For example, let T=[100:200], and A(T0) and k are constant known values.
for T=T1, I want to calculate the following:
I(T1)=A(T0).* exp(T1)
A(T1)=I(T1).* k


However, for T=T2, I want to calculate:
I(T2)= A(T1).* exp(T2)
A(T2)=I(T2).*k

and,

fot T=T3,
I(T3)= A(T2).* exp(T3)....and so on.
A(T3)=I(T3)
Thanks
  

Subject: Concerning the loop functions

From: Steven Lord

Date: 9 Jun, 2014 13:52:22

Message: 2 of 2


"Amr Sadek" <dr_amrsadek@hotmail.com> wrote in message
news:lmu8t8$7hj$1@newscl01ah.mathworks.com...
> Hello,
> How can I use the final results obtained from the first iteration of the
> loop in the second iteration of the same loop?
> For example, let T=[100:200], and A(T0) and k are constant known values.
> for T=T1, I want to calculate the following: I(T1)=A(T0).* exp(T1)
> A(T1)=I(T1).* k

Don't think of your variables as T0, T1, etc. Think of them as T(1), T(2),
T(thisElement), T(thisElement-1), etc. Keep in mind, though, that while
you've referred to a T0 that the first element of an array in MATLAB is
element 1 NOT element 0.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us