Path: news.mathworks.com!not-for-mail
From: "salman " <salmanabdullah9@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Error using times, Matrix dimensions must agree
Date: Tue, 17 May 2011 05:39:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 50
Message-ID: <iqt1lm$7pi$1@newscl01ah.mathworks.com>
References: <iqsrio$kfj$1@newscl01ah.mathworks.com> <iqssvn$ob1$1@newscl01ah.mathworks.com>
Reply-To: "salman " <salmanabdullah9@gmail.com>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1305610742 7986 172.30.248.45 (17 May 2011 05:39:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 17 May 2011 05:39:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2784299
Xref: news.mathworks.com comp.soft-sys.matlab:727176

"Roger Stafford" wrote in message <iqssvn$ob1$1@newscl01ah.mathworks.com>...
> "salman " <salmanabdullah9@gmail.com> wrote in message <iqsrio$kfj$1@newscl01ah.mathworks.com>...
> > 
> > Dear friends,
> > 
> > Have a good day,
> > 
> > i am getting this message "Error using times, MD must agree",
> > here are my three lines of code;
> > 
> > t=linspace(0,.0000001,200)
> > z=linspace(-.0002,.0002,200);
> > Initial_value=(exp(-(z.^2)./L.^2).*cos(z))./z;
> > E_1=vee_1*(Y(:,3).*t)+initial_value.*(z- vee_1*t);%------this is where the error comes 
> > 
> > Y(:,3) is of size 200x1;
> > 
> > 
> > i dont know why this error comes, as i have checked the syntax and logic, it seems correct to me, yet its giving this error.
> > 
> > your help is greatly appreciated.
> > 
> > thanks alot
> - - - - - - - -
>   The multiplication in "(Y(:,3).*t)" is invalid since Y(:,3) is a column vector and t is a row vector.  They must be the same size to use ".*".  Also you should make sure that "vee_1" is a scalar or you will have other troubles.
> 
> Roger Stafford

Dear Roger,

if i change the above equation and replace Y(:,3) by [Y(:,3)]', so now this becomes and row vector. after this however, the previous error is gone, but now i want to create the mesh from t and z and then get surface plot for E(z,t). but it says

Warning: Matrix dimensions must agree, not rendering mesh.

i used this one;

E_1=vee_1*((Y(:,3))'.*t)+Initial_value.*(z- t);
meshgrid(t,z);
surf(t,z,E_1)

where;

size(z)=1 200
size(t)=1 200
size(Y(:,3)')=1 200
size(Initial_value)=1 200, 

i will be grateful for help.

thanks