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:
Labeling and saving results from a loop

Subject: Labeling and saving results from a loop

From: Aaron

Date: 12 Apr, 2011 18:51:04

Message: 1 of 2

I am trying to set up a convergence criteria for my loop. To do so, I wanted to save my estimation results from iteration n as something like beta_n in order to find beta_n - beta_n-1. I am sure this is very basic stuff, but I can't seem to find a way to label the results according to the iteration count. Can anyone point me in the right direction?
Thanks!

Subject: Labeling and saving results from a loop

From: Florin Neacsu

Date: 12 Apr, 2011 19:05:23

Message: 2 of 2

"Aaron " <azoecon@gmail.com> wrote in message <io26uo$ogq$1@fred.mathworks.com>...
> I am trying to set up a convergence criteria for my loop. To do so, I wanted to save my estimation results from iteration n as something like beta_n in order to find beta_n - beta_n-1. I am sure this is very basic stuff, but I can't seem to find a way to label the results according to the iteration count. Can anyone point me in the right direction?
> Thanks!
Hi,
You could try this :
 
previous_beta=0;
for ii=...
   ...
   ...
   beta= ...
  ...
  err = beta-previous_beta;
  previous_beta=beta;
end

This will only provide information from the previous computation. If you want to store all betas try this

beta=zeros(1,n)
for ii=...
   ...
   ...
   betaaaaa= ...
  beta(ii)=betaaaaa;

end

Regards,
Florin

Tags for this Thread

No tags are associated with 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