debugging from symbolic computations
3 views (last 30 days)
Show older comments
Hello. I have written a symbolic code and it works and gets answers but, in command window, when the result is printing, many warning is also printing.
I'm not sure that these warnings can influence on results or not and how can I omit these warnings. Thank you in advance for any help to solve this problem
the code is brought at below. Desired outputs are: k11, k12,k13, ... , k55 with matlab function mode (that are produced with matlabfunction command)
clc
clear
close all
syms a b A B C D E
syms ru0 h r A11 A12 A16 A22 A26 A66 D11 D12 D16 D22 D26 D66 A44 A45 A55 B11 B12 B16 B22 B26 B66
syms U V W X Y del_U del_V del_W del_X del_Y i j k l
syms ru0 h r A11 A12 A16 A22 A26 A66 D11 D12 D16 D22 D26 D66 A44 A45 A55
syms tx(i,x) ty(j,y) rux(x) ruy(y) rvx(x) rvy(y) rwx(x) rwy(y) rxx(x) rxy(y) ryx(x) ryy(y)
kc=5/6;
piu(i,x)=rux(x)*tx(i,x);
pju(j,y)=ruy(y)*ty(j,y);
piv(i,x)=rvx(x)*tx(i,x);
pjv(j,y)=rvy(y)*ty(j,y);
piw(i,x)=rwx(x)*tx(i,x);
pjw(j,y)=rwy(y)*ty(j,y);
pix(i,x)=rxx(x)*tx(i,x);
pjx(j,y)=rxy(y)*ty(j,y);
piy(i,x)=ryx(x)*tx(i,x);
pjy(j,y)=ryy(y)*ty(j,y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
u1=U*piu(i,x)*pju(j,y);
v1=V*piv(i,x)*pjv(j,y);
w1=W*piw(i,x)*pjw(j,y);
fix1=X*pix(i,x)*pjx(j,y);
fiy1=Y*piy(i,x)*pjy(j,y);
u2=del_U*piu(k,x)*pju(l,y);
v2=del_V*piv(k,x)*pjv(l,y);
w2=del_W*piw(k,x)*pjw(l,y);
fix2=del_X*pix(k,x)*pjx(l,y);
fiy2=del_Y*piy(k,x)*pjy(l,y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K11=A11*diff(u1*u2,x,2)+2*A16/r*diff(u1*u2,x,y)+A66/r^2*diff(u1*u2,y,2);
K12=A16*diff(v1*u2,x,2)+(A12+A66)/r*diff(v1*u2,x,y)+A26/r^2*diff(v1*u2,y,2);
K13=A12/r*diff(w1*u2,x)+A26/r^2*diff(w1*u2,y);
K14=0;
K15=0;
%%%%%%%%%%%%%%%%%%
K22=A66*diff(v1*v2,x,2)+2*A26/r*diff(v1*v2,x,y)+A22/r^2*diff(v1*v2,y,2)-kc*A44/r^2*v1*v2;
K23=A26/r*diff(w1*v2,x)+(A22+kc*A44)/r^2*diff(w1*v2,y);
K24=0;
K25=kc*A44/r*fiy1*v2;
%%%%%%%%%%%%%%%%%%%%%%%%%%
K33=-kc*A55*diff(w1*w2,x,2)-kc*A44/r^2*diff(w1*w2,y,2)+A22/r^2*w1*w2;
K34=-kc*A55*diff(fix1*w2,x);
K35=-kc*A44/r*diff(fiy1*w2,y);
%%%%%%%%%%%%%%%%
K44=-kc*A55*fix1*fix2+D11*diff(fix1*fix2,x,2)+2*D16/r*diff(fix1*fix2,x,y)+D66/r^2*diff(fix1*fix2,y,2);
K45=D16*diff(fiy1*fix2,x,2)+(D12+D66)/r*diff(fiy1*fix2,x,y)+D26/r^2*diff(fiy1*fix2,y,2);
%%%%%%%%%%%%%%%%%%%%%
K55=-kc*A44*fiy1*fiy2+D66*diff(fiy1*fiy2,x,2)+2*D26/r*diff(fiy1*fiy2,x,y)+D22/r^2*diff(fiy1*fiy2,y,2);
K11=diff(diff(K11,del_U),U);K12=diff(diff(K12,del_U),V);K13=diff(diff(K13,del_U),W);K14=diff(diff(K14,del_U),X);K15=diff(diff(K15,del_U),Y);
K22=diff(diff(K22,del_V),V);K23=diff(diff(K23,del_V),W);K24=diff(diff(K24,del_V),X);K25=diff(diff(K25,del_V),Y);
K33=diff(diff(K33,del_W),W);K34=diff(diff(K34,del_W),X);K35=diff(diff(K35,del_W),Y);
K44=diff(diff(K44,del_X),X);K45=diff(diff(K45,del_X),Y);
K55=diff(diff(K55,del_Y),Y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
K11=matlabFunction(K11),K12=matlabFunction(K12),K13=matlabFunction(K13),K14=matlabFunction(K14),K15=matlabFunction(K15)
K22=matlabFunction(K22),K23=matlabFunction(K23),K24=matlabFunction(K24),K25=matlabFunction(K25),
K33=matlabFunction(K33),K34=matlabFunction(K34),K35=matlabFunction(K35),
K44=matlabFunction(K44),K45=matlabFunction(K45),
K55=matlabFunction(K55)
0 Comments
Answers (1)
Tejas
on 20 Sep 2024
Hello Pooya,
The warnings that appear after running the code suggest that the functions 'tx(i,x)', 'ty(j,y)', 'rux(x)', 'ruy(y)', 'rvx(x)', 'rvy(y)', 'rwx(x)', 'rwy(y)', 'rxx(x)', 'rxy(y)', 'ryx(x)' and 'ryy(y)' are invalid. I am assuming that these functions are symbolic functions and not local functions defined outside this MATLAB file.
The warnings appear because these functions are not explicitly defined with known operations or expressions. MATLAB is unable to recognize the behaviour or output of these functions, which might lead to them being misinterpreted and affecting the final result.
Defining these functions explicitly will resolve the issue. Below is an example code snippet demonstrating how the operations within these functions can be defined:
syms x y i j
% Example expressions (replace with actual expressions as needed)
tx(i, x) = sin(i * x);
ty(j, y) = cos(j * y);
rux(x) = exp(x);
ruy(y) = exp(y);
rvx(x) = x^2;
rvy(y) = y^2;
rwx(x) = log(x + 1);
rwy(y) = log(y + 1);
rxx(x) = x^3;
rxy(y) = y^3;
ryx(x) = sqrt(x);
ryy(y) = sqrt(y);
For more information on how to explicitly define symbolic math functions, use the following command to open the documentation:
web(fullfile(docroot, 'symbolic/symfun.html'))
0 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!