Iterative method-Problems with array of symbolic functions
이전 댓글 표시
Hello everyone.
I'm trying to write a code for an iterative method, using symbolic functions, but I have this error when I try to plot:
Error using fplot>singleFplot (line 240). Input must be a function or functions of a single variable.
I think that the problem can be related on the way I am using the sym arrays to store these functions or in the way I am calculating the convolution of sym functions (it is the only part of the code where i use a function of more than 1 variable).
Do you know if these is a more effective way to write the convolution?
Here is the code:
N=5;
k=0.01;
syms x y;
E = sym(zeros(N,1));
L = sym(zeros(N,1));
F = sym(zeros(N,1));
f(x,y)=-sqrt(3)/pi*sinh(2*x-2*y)/sinh(3*x-3*y);
A=2*log(2/k);
E(1)=k*cosh(y);
figure(); hold on
for i=1:3
L(i)=log(1+exp(-E(i)));
F(i)=int(f(x,y)*L(i),y,-A,A); %convolution
E(i+1)=E(1)+F(i);
if i==3
fplot(L(i),[-10,10]);
break;
else
continue;
end
end
hold off
Thank you very much.
--------------------EDIT-------------------------
I've changed the method to perform the convolution, and now I don't have errors anymore.
If I plot L(1) (see below) no problems, but when I try to plot L(i) (for example L(3)) I have an empty graph. Maybe there are still some problems when I try to fill the L array?
N=5;
k=0.01;
syms x y w;
E = sym(zeros(N,1));
L = sym(zeros(N,1));
f(x)=-sqrt(3)/pi*sinh(2*x)/sinh(3*x);
g(w)=fourier(f);
A=2*log(2/k);
E(1)=k*cosh(x);
figure(); hold on
for i=1:3
L(i)=log(1+exp(-E(i)));
h(w)=fourier(L(i));
l(w)=g*h;
s(x)=ifourier(l);
E(i+1)=k*cosh(x)+s;
if i==3
%fplot(L(1),[-10,10]); %This works
fplot(L(i),[-10,10]); %Doesn't work
break;
else
continue;
end
end
hold off
댓글 수: 2
Star Strider
2019년 12월 14일
The ‘L’ function is a function of x and y. Trying to plot it with fplot throws an error reflecting that, and it is seenttially impossible to plot it with fsurf.
It would likely be much more efficient to do this numerically and avoid the Symbolic Math Toolbox.
I cannot figure out from your code what you want to do.
Tommaso Franzini
2019년 12월 14일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Code Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!