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:
Wrong Size

Subject: Wrong Size

From: yang

Date: 30 Jun, 2009 20:10:17

Message: 1 of 4

Hi everyone,
I tried to use Matlab to calculate the following
____________________________________
R=rand(1,2);
unit=[1.0;1.0];
a=[0.0,0.0];
for I = 1: m
           sm(I)=0.0;
           for L= m-I+1: m
           sm(I)=sm(I)+a(L);
           end
       S=1.0/(I+sm(I));
       G(I)=[R(I)].^S;
           end
       PROD=1.0;
                for k = 1:m
       PROD=PROD * G(m+1-k);
       x(k)=1.0-PROD;
    U(k)=log(x(k)/(1-x(k)));
                end
_______________________________________
The problem is that G is 2X2 matrix also U is 2X2 matrix. I will be grateful if you help me for getting G and U as vector 1X2 or 2X1.

Thank you very much

hassan010012@yahoo.com

Subject: Wrong Size

From: Ravi

Date: 1 Jul, 2009 19:33:01

Message: 2 of 4

"yang " <macmaster_egypt@yahoogroups.com> wrote in message <h2drf9$rb4$1@fred.mathworks.com>...
> Hi everyone,
> I tried to use Matlab to calculate the following
> ____________________________________
> R=rand(1,2);
> unit=[1.0;1.0];
> a=[0.0,0.0];
> for I = 1: m
> sm(I)=0.0;
> for L= m-I+1: m
> sm(I)=sm(I)+a(L);
> end
> S=1.0/(I+sm(I));
> G(I)=[R(I)].^S;
> end
> PROD=1.0;
> for k = 1:m
> PROD=PROD * G(m+1-k);
> x(k)=1.0-PROD;
> U(k)=log(x(k)/(1-x(k)));
> end
> _______________________________________
> The problem is that G is 2X2 matrix also U is 2X2 matrix. I will be grateful if you help me for getting G and U as vector 1X2 or 2X1.
>
> Thank you very much
>
> hassan010012@yahoo.com


what is the value of m?

Subject: Wrong Size

From: yang

Date: 2 Jul, 2009 12:47:01

Message: 3 of 4

 Hi everyone,
 I tried to use Matlab to calculate the following
 ____________________________________
m=2;
> R=rand(1,2);
 > unit=[1.0;1.0];
 > a=[0.0,0.0];
 > for I = 1: m
 > sm(I)=0.0;
 > for L= m-I+1: m
 > sm(I)=sm(I)+a(L);
 > end
 > S=1.0/(I+sm(I));
 > G(I)=[R(I)].^S;
 > end
 > PROD=1.0;
 > for k = 1:m
 > PROD=PROD * G(m+1-k);
 > x(k)=1.0-PROD;
 > U(k)=log(x(k)/(1-x(k)));
 > end
> _______________________________________
 The problem is that random numbers R changes for each run I want it not to be changed.

 Thank you very much

 hassan010012@yahoo.com


> what is the value of m?

Subject: Wrong Size

From: Ravi

Date: 2 Jul, 2009 14:55:03

Message: 4 of 4

save and use the same state...use somethin like this as mentioned in help for the rand function
 % initialize somewhere in begining and there after use the following two lines
s = rand('twister');

rand('twister',s);
R = rand(1,2);


"yang " <macmaster_egypt@yahoogroups.com> wrote in message <h2ia85$aq3$1@fred.mathworks.com>...
> Hi everyone,
> I tried to use Matlab to calculate the following
> ____________________________________
> m=2;
> > R=rand(1,2);
> > unit=[1.0;1.0];
> > a=[0.0,0.0];
> > for I = 1: m
> > sm(I)=0.0;
> > for L= m-I+1: m
> > sm(I)=sm(I)+a(L);
> > end
> > S=1.0/(I+sm(I));
> > G(I)=[R(I)].^S;
> > end
> > PROD=1.0;
> > for k = 1:m
> > PROD=PROD * G(m+1-k);
> > x(k)=1.0-PROD;
> > U(k)=log(x(k)/(1-x(k)));
> > end
> > _______________________________________
> The problem is that random numbers R changes for each run I want it not to be changed.
>
> Thank you very much
>
> hassan010012@yahoo.com
>
>
> > what is the value of m?

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