Path: news.mathworks.com!not-for-mail
From: "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi>
Newsgroups: comp.soft-sys.matlab
Subject: Re: About the element of Matrix in Matlab
Date: Mon, 26 Oct 2009 08:26:01 +0000 (UTC)
Organization: Tampere University of Technology
Lines: 63
Message-ID: <hc3mep$65o$1@fred.mathworks.com>
References: <hc3956$el9$1@fred.mathworks.com> <wS9Fm.48948$Lw1.8356@newsfe03.iad>
Reply-To: "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1256545561 6328 172.30.248.38 (26 Oct 2009 08:26:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 26 Oct 2009 08:26:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 218565
Xref: news.mathworks.com comp.soft-sys.matlab:580000


"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