필터 지우기
필터 지우기

Error plotting with space and time

조회 수: 1 (최근 30일)
jojo
jojo 2020년 5월 17일
답변: Image Analyst 2020년 5월 17일
Hello,
I do not understand how to plot/visualize a solution to some function with different time and space steps. I have the below function handle and I need to plot the exact solution to approximate the the error in the approximate solution. Can someone please explain the most efficient method of doing this? I have not calculted the approximation yet, but it will be in a 2x2 array format, please also elaborate on plotting the error.
%attempt
sigma=12
alpha=0.01
exact = @(t,x) exp(-(x-0.4).^2/(2*alphat + 1/sigma))/sqrt(sigma*alpha*t+3);
Nt=200;dt=1/Nt;
Nx=20;dx=1/Nx;
t1=linspace(0,1,dt)
x1=linspace(0,1,dx)
plot(t1,x1,exact(t1,x1)
% How to approach an error analysis/plot?
%I understand it is the delta detween exact and approx at the points in question
% I just need a cleaner/efficient way of doing this

답변 (1개)

Image Analyst
Image Analyst 2020년 5월 17일
There are a number of errors there. Not exactly sure what you want, but is this closer?
% attempt
sigma=12
alpha=0.01
exact = @(t,x) exp(-(x-0.4).^2 ./(2*alpha * t + 1/sigma)) ./ sqrt(sigma*alpha.*t+3);
Nt=200;
dt=1/Nt;
Nx=200;
dx=1/Nx;
t1=linspace(0,1,Nt)
x1=linspace(0,1,Nx)
[t2, x2] = meshgrid(t1, x1);
output = exact(t2,x2)
imshow(output, []);
colormap(jet(256));
colorbar;

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by