Suggestions for my code

Hi all,
I am new to matlab and I have some troubles with my code. I tried to search for some answers but failed. Could anyone give me some suggestions?
clear
[x t]=meshgrid(0:5*10^(-5):200*10^(-5), 0:10:400);
Cxt = 0.0;
for i=0:6,
Cxt = Cxt + (-1)^i*erfc((2*(i+1)*200*10^(-5)-x) / (2*sqrt(t*1.04*10^(-6)))) + (-1)^i*erfc((2*i*200*10^(-7) + x) / (2*sqrt(t*1.04*10^(-6))));
end
mesh(x, t, Cxt)
I just want to have a 3d plot of Cxt, which is a function of x and t. But I always got the warning of "Warning: Matrix is singular to working precision" and no graphic output.
Thanks for help!

回答(1 个)

When doing element-by-element computations, use .* .^ and ./
clear
[x t]=meshgrid(0:5*10^(-5):200*10^(-5), 0:10:400);
Cxt = 0.0;
for i=0:6,
Cxt = Cxt + (-1)^i*erfc((2*(i+1)*200*10^(-5)-x) ./ (2*sqrt(t*1.04*10^(-6)))) + (-1)^i*erfc((2*i*200*10^(-7) + x) ./ (2*sqrt(t*1.04*10^(-6))));
end
mesh(x, t, Cxt)

类别

帮助中心File Exchange 中查找有关 Polar Plots 的更多信息

标签

提问:

2011-4-23

Community Treasure Hunt

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

Start Hunting!

Translated by