Thread Subject: About the element of Matrix in Matlab

Subject: About the element of Matrix in Matlab

From: Viet Dang

Date: 26 Oct, 2009 04:39:02

Message: 1 of 4

I have a difficulty in using Matlab to create a matrix. The matrix have its element is a random function of time-varying valuable t such as Gaussian or Sin. When t changes the matrix is changed and my system will use this matrix to calculate.

My example:

A is a square matrix 3,3.

A(1,1) = 2 sin(t), A(1,2)=1 sin(t), A(1,3)= 3cos(t).
A(2,1) = 1 cos(t),A(2,2) = 3sin(t), A(2,3) = 2cos(t).
A (3,1)= 0.5sin(t),A(3,2) = 1.5sin(t),A(3,3)=3sin(t).

A will be changed when t is running. So how I can matrix A to calculate. Please help me about Matlab code. Thanks.

Subject: About the element of Matrix in Matlab

From: Nasser M. Abbasi

Date: 26 Oct, 2009 04:48:22

Message: 2 of 4


"Viet Dang" <muaphongba@yahoo.com> wrote in message
news:hc3956$el9$1@fred.mathworks.com...
>I have a difficulty in using Matlab to create a matrix. The matrix have its
>element is a random function of time-varying valuable t such as Gaussian
>or Sin. When t changes the matrix is changed and my system will use this
>matrix to calculate.
>
> My example:
>
> A is a square matrix 3,3.
>
> A(1,1) = 2 sin(t), A(1,2)=1 sin(t), A(1,3)= 3cos(t).
> A(2,1) = 1 cos(t),A(2,2) = 3sin(t), A(2,3) = 2cos(t).
> A (3,1)= 0.5sin(t),A(3,2) = 1.5sin(t),A(3,3)=3sin(t).
>
> A will be changed when t is running. So how I can matrix A to calculate.
> Please help me about Matlab code. Thanks.


syms t
A=[2*sin(t) sin(t) 3*cos(t);
   cos(t) 3*sin(t) 2*cos(t);
   0.5*sin(t) 5*sin(t) 3*sin(t)]

EDU>> for time=1:3
          subs(A,t,time)
      end


    1.6829 0.8415 1.6209
    0.5403 2.5244 1.0806
    0.4207 4.2074 2.5244


    1.8186 0.9093 -1.2484
   -0.4161 2.7279 -0.8323
    0.4546 4.5465 2.7279

    0.2822 0.1411 -2.9700
   -0.9900 0.4234 -1.9800
    0.0706 0.7056 0.4234

etc...

--Nasser

Subject: About the element of Matrix in Matlab

From: Pekka Kumpulainen

Date: 26 Oct, 2009 08:26:01

Message: 3 of 4

"Nasser M. Abbasi" <nma@12000.org> wrote in message <wS9Fm.48948$Lw1.8356@newsfe03.iad>...
>
> "Viet Dang" <muaphongba@yahoo.com> wrote in message
> news:hc3956$el9$1@fred.mathworks.com...
> >I have a difficulty in using Matlab to create a matrix. The matrix have its
> >element is a random function of time-varying valuable t such as Gaussian
> >or Sin. When t changes the matrix is changed and my system will use this
> >matrix to calculate.
> >
> > My example:
> >
> > A is a square matrix 3,3.
> >
> > A(1,1) = 2 sin(t), A(1,2)=1 sin(t), A(1,3)= 3cos(t).
> > A(2,1) = 1 cos(t),A(2,2) = 3sin(t), A(2,3) = 2cos(t).
> > A (3,1)= 0.5sin(t),A(3,2) = 1.5sin(t),A(3,3)=3sin(t).
> >
> > A will be changed when t is running. So how I can matrix A to calculate.
> > Please help me about Matlab code. Thanks.
>
>
> syms t
> A=[2*sin(t) sin(t) 3*cos(t);
> cos(t) 3*sin(t) 2*cos(t);
> 0.5*sin(t) 5*sin(t) 3*sin(t)]
>
> EDU>> for time=1:3
> subs(A,t,time)
> end
>
>
> 1.6829 0.8415 1.6209
> 0.5403 2.5244 1.0806
> 0.4207 4.2074 2.5244
>
>
> 1.8186 0.9093 -1.2484
> -0.4161 2.7279 -0.8323
> 0.4546 4.5465 2.7279
>
> 0.2822 0.1411 -2.9700
> -0.9900 0.4234 -1.9800
> 0.0706 0.7056 0.4234
>
> etc...
>
> --Nasser
>

Or if you don't have the symbolic toolbox:
A = @(t) [2*sin(t) 1*sin(t) 3*cos(t)
    1*cos(t) 3*sin(t) 2*cos(t)
    0.5*sin(t) 1.5*sin(t) 3*sin(t)];

>> A(0)
ans =
     0 0 3
     1 0 2
     0 0 0

for t = 0:.1:1
    A(t)
end

Subject: About the element of Matrix in Matlab

From: Viet Dang

Date: 7 Nov, 2009 09:14:03

Message: 4 of 4

Dear friends.

I am coding to solve the problem of uncertain delta A in the system such as:

xdot = (A1+A)*x(t) + B1*u(t).
y = C1*x(t)+w(t)

If I have A1,B1,C1 is the fix matrix such as A1= [1 2 3;4 2 1;2 2 5]; B1 =[1;0;0];C1 = [1 0 0;1 -1 0;1 0 1]; w(t) = sin(2t+2); u(t) = sin(t);

and A is the above matrix;

Would you like to support to me the way of plot the (x,t), with initial condition x(0)=(0.2;0.5;2).

Thanks.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
matrix Viet Dang 26 Oct, 2009 00:44:02
element Viet Dang 26 Oct, 2009 00:44:02
matlab code Viet Dang 26 Oct, 2009 00:44:02
rssFeed for this Thread

Contact us at files@mathworks.com