Suggestions for my code
3 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Matt Fig
on 23 Apr 2011
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)
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!