Compute function of two variables
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Jan
el 28 de En. de 2017
Is this the complete error message? It tells only, where the problem occurres, but not, what the problem is.
Respuestas (1)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!