Calculating of multivariate symbolic expression with numeric data

HI
I need to calculate integral over a Multivariate function,
the function is a product of some 3x3 "analytic" matrices which can be easily calculated using symbolic math,
Here is a simple function which I need to calculate :
syms t p
R=[ cos(p) sin(p) 0
-sin(p) cos(p) 0
0 0 1];
L1=[ cos(t) 0 sin(t)
0 1 0
-sin(t) 0 cos(t) ];
e0=[1;1;1]
F=inv(R)*inv(L1)*R*e0
the result :
F =
sin(p)^2 - cos(p)*sin(t) - cos(p)*sin(p) + cos(p)^2*cos(t) + cos(p)*cos(t)*sin(p)
cos(p)^2 - sin(p)*sin(t) - cos(p)*sin(p) + cos(t)*sin(p)^2 + cos(p)*cos(t)*sin(p)
cos(t) + cos(p)*sin(t) + sin(p)*sin(t)
After having the function what is the best way to calculate it over a set of numerical data for p,t (phi,theta) ??
10x

 Akzeptierte Antwort

Fnum = matlabFunction(F, p, t);
This would create a MATLAB function that had p as its first argument and t as its second argument and which returned an array of numeric values.

4 Kommentare

Hi,
thanks for your resopne, i tried it but it doesn't work
i also tried a simple function and still cant make it work.
how do you use it after converting it to matlab function?
simple function:
syms t p
R=sqrt(t*t+p*p);
Fnum = matlabFunction(R, p, t);
x=-5:1:5 ;
[X Y]=meshgrid(x,x);
[X1 Y1]=Fnum(X,Y)
[X2 Y2]=Fnum(1,1)
10x again
Those forms should work, it appears to me. What shows up if you display Fnum ?
Try:
Fnum = matlabFunction(R, 'vars', [p, t]);
Thank u both, The last line gives the solution.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Robust Control Toolbox finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by