DSPRelated.com
Forums

MATLAB Code Correction .....

Started by chel...@yahoo.co.in March 5, 2010
Hi Experts,

My aim is to calculate the value of 'a'.For that first we have to find 'out'(see in the program) then differentiate that with respect to 'a' and equate to '0'.

In the following coding I can't able to calculate out1, out2, out3.
It is giving error. So anyone can solve it for me please....

(I can't able to type the equation here. If anyone need I will send to you through mail).

syms r z

m=0.063;
ep.13;
xmin=1;
xmax=L;
ymin=-L/2;
ymax=L/2;

w= cos((pi*z)/L)*exp(-a*sqrt(r.^2+z.^2));
w1 = r*(cos((pi*z))*exp(-a*sqrt(r.^2+z.^2)))^2;
normal = inline(vectorize(w1),'r','z');
potential = w^2*(r/(sqrt(r.^2+z.^2)));
y1= vectorize(r*diff(diff(w,r)));
y2= vectorize(diff(w,r));
y3= vectorize((r)*diff(diff(w,z)));

f1 = inline(y1,'r','z');
f2 = inline(y2,'r','z');
f3 = inline(y3,'r','z');
poten = inline(vectorize(potential),'r','z');

normalize(L) = dblquad(normal ,xmin,xmax,ymin,ymax,[],@quad);

out1 = dblquad(f1,xmin,xmax,ymin,ymax);
out2 = dblquad(f2,xmin,xmax,ymin,ymax,[],@quad);
out3 = dblquad(f3,xmin,xmax,ymin,ymax,[],@quad);

out = out1+out2+out3;

Thank you,
Swamy
Hello,

I don't think you can calculate a from this since you are using it's value on the 9th line. Also you need to define L. If you put these definitions your code will run (that is the value of out will be computed)

________________________________
From: "c...@yahoo.co.in"
To: m...
Sent: Thu, March 4, 2010 4:43:34 AM
Subject: [matlab] MATLAB Code Correction .....

Hi Experts,

My aim is to calculate the value of 'a'.For that first we have to find 'out'(see in the program) then differentiate that with respect to 'a' and equate to '0'.

In the following coding I can't able to calculate out1, out2, out3.
It is giving error. So anyone can solve it for me please....

(I can't able to type the equation here. If anyone need I will send to you through mail).

syms r z

m=0.063;
ep.13;
xmin=1;
xmax=L;
ymin=-L/2;
ymax=L/2;
w= cos((pi*z)/L) *exp(-a*sqrt( r.^2+z.^2) );
w1 = r*(cos((pi*z) )*exp(-a* sqrt(r.^2+ z.^2)))^2;
normal = inline(vectorize( w1),'r',' z');
potential = w^2*(r/(sqrt( r.^2+z.^2) ));
y1= vectorize(r* diff(diff( w,r)));
y2= vectorize(diff( w,r));
y3= vectorize((r) *diff(diff( w,z)));

f1 = inline(y1,'r' ,'z');
f2 = inline(y2,'r' ,'z');
f3 = inline(y3,'r' ,'z');
poten = inline(vectorize( potential) ,'r','z') ;

normalize(L) = dblquad(normal ,xmin,xmax,ymin, ymax,[],@ quad);
out1 = dblquad(f1,xmin, xmax,ymin, ymax);
out2 = dblquad(f2,xmin, xmax,ymin, ymax,[],@ quad);
out3 = dblquad(f3,xmin, xmax,ymin, ymax,[],@ quad);

out = out1+out2+out3;

Thank you,
Swamy