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:
store data in a vector and meanvalue problems..

Subject: store data in a vector and meanvalue problems..

From: Lyle Cole

Date: 1 Oct, 2010 13:37:09

Message: 1 of 2

heyya,

Am writing a m-file and it didnt took long before i ran into troubles.
I want to calculate the mean value of the time it takes to solve a LES consisting of randomized matrices.


for i=1:20;
    A=rand(n);
    b=rand(n,1);
    tic;
    x=A\b;
    t(i)=toc
end
t1=mean(t)

This is what I had in mind. However, I don't know if it's right though.
Moreover, is there anyway I can store data such as t1 in a vector if I want to calculate for some specific values of n and save them in a vector.

Thanks

Subject: store data in a vector and meanvalue problems..

From: Sean

Date: 1 Oct, 2010 13:55:47

Message: 2 of 2

"Lyle Cole" <cribbe_86@hotmail.com> wrote in message <i84o65$p6$1@fred.mathworks.com>...
> heyya,
>
> Am writing a m-file and it didnt took long before i ran into troubles.
> I want to calculate the mean value of the time it takes to solve a LES consisting of randomized matrices.
>
>
> for i=1:20;
       A=rand(n);
> b=rand(n,1);
> tic;
> x=A\b;
> t(i)=toc
> end
> t1=mean(t)
>
> This is what I had in mind. However, I don't know if it's right though.
> Moreover, is there anyway I can store data such as t1 in a vector if I want to calculate for some specific values of n and save them in a vector.

That looks right to me.

For saving your t1 values just make a second loop
tstored = zeros(1,20);
for n = 3:20
  your loop
  tstored(n) = mean(t)
end

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