Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Help please
Posted:
Dec 5, 2012 7:44 AM


"Ziga" wrote in message <k9nd24$svi$1@newscl01ah.mathworks.com>... > "Nasser M. Abbasi" wrote in message <k9nbtn$22s$2@speranza.aioe.org>... > > On 12/5/2012 5:28 AM, Ziga wrote: > > > I am new to matlab and I have a problem. Can someone please help me to write matlab program for this: > > > > > > P(t(i))=A*P(t(i1)) > > > i=1:10 > > > P(t(0))=[1;0;0] > > > A=[0,8901 0,5278 0,5612 ; 0,0352 0,2083 0,0459 ; 0,0747 0,2639 0,3929] > > > > > > So i have to start with: > > > P(t(1))=A*P(t(0)) > > > and so on > > > > > > I would also like to make histgram for results i=1:10. > > > > > > Thank you a lot > > > > > > Ziga > > > > > > > > > can you Type A in correct Matlab syntat? what is 0,8901 > > suppose to mean? > > > > Nasser > > A is matrix and 0,8901 is number. I have that written on the paper and I would like to use matlab to give me results. I have no idea how to transform that and use it in matlab....
What Nasser is trying to tell you is that ML uses the period as the decimal separator, not the comma. So when your program runs, it sees A=[0 8901 0 5278 0 5612; 0 352 0 2083 0 459; 0 747 0 2639 0 3929]
Remember, by the way, that ML uses i and j for sqrt(1) for defining complex numbers. You could run into problems if you redefine i as one of your variables. You should be getting the error message: *Subscript indices must either be real positive integers or logicals.* at the line P(t(i))=A*P(t(i1)) because you haven't yet redefined i. As a result, you are in effect trying to access t(sqrt(1)), which is illegal.
t(0) is also illegal in ML and should generate an error message. Unlike some other programming languages, indexing in ML must start with a positive integernot zero.
Matlab includes a pretty good tutorial, Getting Started, in their help files. You may want to work through that and then come back here with questions if you don't understand the documentation.
Barry



