Compute function of two variables
이전 댓글 표시
I have a function Ux=f(x,t) where f(x,t) is an infinite sine series (which I've truncated at 50 terms). I want to find the values of Ux at every x and t and out put it as a matrix (# of x values X #of t values), then plot a contour of where Ux is zero on a 2-D plot of x vs t (I want t on the y-axis). Here's what I've tried so far:
syms x t
%Establish An Coefficients
n=0;
for m=1:1:50
n=n+1;
if n==2
A(n)=0.5;
else
A(n)=(-4*sin(.5*pi*m))/((pi*m^2)-(4*pi));
end
end
%Determine T(t) Values for each Value of An
index=0;
for n=1:1:50
index=index+1;
T(index)=exp(-(n^2)*(pi^2)*t);
end
%Find values of X'(x)
index=0;
for n=1:1:50
index=index+1;
dX(index)=(A(n))*(n*pi)*cos(n*pi*x);
end
Ux=(sum(dX.*T));
x=.2:.01:.75;
t=0:.005:.5;
Flux=eval(Ux);
[A,B] = meshgrid(x,t);
v=[0,0];
figure
contour(A,B,Flux,v)
so x is 1 X 56 matrix and t is a 1 X 101 matrix. My understanding is that to make the contour part work I need 'Flux' to output as a 56 X 101 matrix. I keep getting the following error:
Error in sym/eval (line 11)
s = evalin('caller',vectorize(map2mat(char(x))));
Error in zeroflux (line 42)
Flux=eval(Ux);
댓글 수: 2
Jan
2017년 1월 28일
Is this the complete error message? It tells only, where the problem occurres, but not, what the problem is.
Justin Bruh
2017년 1월 28일
답변 (1개)
Justin Bruh
2017년 1월 28일
카테고리
도움말 센터 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!