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:
Matrix dimensions not agree, not rendering mesh. please help

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: salman

Date: 7 May, 2011 07:03:04

Message: 1 of 7

Dear friends,

please have a look at the code that i have, there is some small problem here;

t=linspace(0,.00000001,200);
z=linspace(0,.0001,200);
s=[1,0,0,0,0,0,0,0,0];
[t,y]=ode45(@fname,t,s);
z1=i*21445.*y(:,3)*z-21445*(t-z);---------A
size(z1)
size(t)
size(z)
surf(z1,z,t);

i want to plot the equation A, i.e. z1 Vs Time vs Distance, but there is some dimension problem, i would be highly obliged for your help.

Thanks alot

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: Sadik

Date: 7 May, 2011 17:26:04

Message: 2 of 7

Salman,

Could you also paste fname.m below? It is required by the piece of code you have written.

Best.

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: salman

Date: 8 May, 2011 00:59:04

Message: 3 of 7

"Sadik " <sadik.hava@gmail.com> wrote in message <iq3vbc$93m$1@newscl01ah.mathworks.com>...
> Salman,
>
> Could you also paste fname.m below? It is required by the piece of code you have written.
>
> Best.

Yes sure!

here is the fname code;

dydt(1)=-k1*y(3)+k1*y(7)+k5*y(9);
dydt(5)=-k2*y(6)+k2*y(8);
dydt(9)=k1*y(3)+k2*y(6)-k1*y(7)-k2*y(8)-k5*y(9);
dydt(2)=-k3*y(2)-k2*y(3)+k1*y(8);
dydt(3)=-k1*y(1)-k2*y(2)-k4*y(3)+k1*y(9);
dydt(4)=-k3*y(4)-k1*y(6)+k2*y(7);
dydt(6)=-k1*y(4)-k2*y(5)+k2*y(9)-k6*y(6);%
dydt(7)=k1*y(1)+k2*y(4)-k4*y(7)-k1*y(9);
dydt(8)=k1*y(2)+k2*y(5)-k6*y(8);%-----

thank you very much!

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: Sadik

Date: 8 May, 2011 01:23:04

Message: 4 of 7

Hi Salman,

Actually you should copy and paste EVERYTHING in the file. You should have

k1 = ...
k2 = ...

type of lines in fname.m.

Best.

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: salman

Date: 8 May, 2011 01:32:05

Message: 5 of 7

"Sadik " <sadik.hava@gmail.com> wrote in message <iq4r9o$7v7$1@newscl01ah.mathworks.com>...
> Hi Salman,
>
> Actually you should copy and paste EVERYTHING in the file. You should have
>
> k1 = ...
> k2 = ...
>
> type of lines in fname.m.
>
> Best.

Here it is,

k5=1000000000;%Excited state optical decay,1000 MHz
k2=10*i*k5/2; %Rabi frequency of the coupling beam
k1=k2/10; %Rabi freq of the probe beam
k3=0; %Spin decay between the lower states (Ground states)
k4=k5/2; %Decay rate between the ground and excited state, i.e. small Gamma ab
k6=k4; %decay between the metastable and excited state
%----------------------------------------------------------------%
dydt(1)=-k1*y(3)+k1*y(7)+k5*y(9);%Pop of the ground state
dydt(5)=-k2*y(6)+k2*y(8);%Pop of the metastable state
dydt(9)=k1*y(3)+k2*y(6)-k1*y(7)-k2*y(8)-k5*y(9);%Pop of the excited state
dydt(2)=-k3*y(2)-k2*y(3)+k1*y(8);%Ground states coherence
dydt(3)=-k1*y(1)-k2*y(2)-k4*y(3)+k1*y(9);%Spin coherence
dydt(4)=-k3*y(4)-k1*y(6)+k2*y(7);
dydt(6)=-k1*y(4)-k2*y(5)+k2*y(9)-k6*y(6);%----------
dydt(7)=k1*y(1)+k2*y(4)-k4*y(7)-k1*y(9);
dydt(8)=k1*y(2)+k2*y(5)-k6*y(8);%-------------------


thank you very much,

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: Sadik

Date: 8 May, 2011 02:48:04

Message: 6 of 7

Hi Salman,

The problem is with the usage of surf. If you want to make a plot of Z1 vs. Z and T, then Z1 should be the third argument.

Here is an example that works, but you will need to modify it if it is not doing what you want theoretically.

t=linspace(0,.00000001,200);
z=linspace(0,.0001,200);
s=[1,0,0,0,0,0,0,0,0];
[t,y]=ode45(@fname,t,s);
[T,Z] = meshgrid(t,z);
Z1=i*21445.*repmat(y(:,3),[1 size(Z,2)]).*Z-21445*(T-Z);
surf(T,Z,abs(Z1))

Best.

Subject: Matrix dimensions not agree, not rendering mesh. please help

From: salman

Date: 8 May, 2011 03:43:02

Message: 7 of 7

"Sadik " <sadik.hava@gmail.com> wrote in message <iq5094$i6c$1@newscl01ah.mathworks.com>...
> Hi Salman,
>
> The problem is with the usage of surf. If you want to make a plot of Z1 vs. Z and T, then Z1 should be the third argument.
>
> Here is an example that works, but you will need to modify it if it is not doing what you want theoretically.
>
> t=linspace(0,.00000001,200);
> z=linspace(0,.0001,200);
> s=[1,0,0,0,0,0,0,0,0];
> [t,y]=ode45(@fname,t,s);
> [T,Z] = meshgrid(t,z);
> Z1=i*21445.*repmat(y(:,3),[1 size(Z,2)]).*Z-21445*(T-Z);
> surf(T,Z,abs(Z1))
>
> Best.


Thank you very much Dear Sadiq,

actually i did it this way, if you would please kindly take a look,

function maxbloch % all the simulation is done for the case of zero probe detuning
t=linspace(0,.00000001,200);
z=linspace(0,.0001,200);
s=[1,0,0,0,0,0,0,0,0];
[t,y]=ode45(@salman3,t,s);
f=repmat(t,1,200);
z1=i*(-2140967)*y(:,3)*z;
g=repmat(z,200,1);
k=z1-23567*(g-z1/34);%the large number is the constant of integration that i have chosen randomly.
surf(t,z,abs(k));

isn't this also correct?

I am thankful for your precious time.

Tags for this Thread

No tags are associated with 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