why i can't get same plot when i change Real to Im?
3 ビュー (過去 30 日間)
古いコメントを表示
i plot the real one but when i change the plot for abs i can get the abs why i can't get that of this function
0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) - 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2
and my code for ploting is
abs(0.2e1 .* (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 .* exp((-27 * t + 3 * x)) + 0.25e2 .* exp((-35 * t + 5 * x + 2))) ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) - 0.2e1 * (0.2e1 .* exp((-8 * t + 2 * x)) + 0.3e1 .* exp((-27 * t + 3 * x)) + 0.5e1 .* exp((-35 * t + 5 * x + 2))) .^ 2 ./ (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 .* x)) + exp((-35 * t + 5 * x + 2))) .^ 2).^2

2 件のコメント
Torsten
2025 年 1 月 24 日
編集済み: Torsten
2025 年 1 月 24 日
I can't see a difference:
f = @(x,t) 0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) - 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2
x = -20:0.1:20;
t = -4:0.1:4;
for i = 1:numel(x)
for j = 1:numel(t)
p(i,j) = f(x(i),t(j));
end
end
figure()
surf(x,t,p.','Edgecolor','none')
figure()
surf(x,t,abs(p.'),'Edgecolor','none')
From the title of your plots, it seems that the name of an array you use is "abs" ? If so, rename it.
Walter Roberson
2025 年 1 月 24 日
In Maple, map(abs,solnum) applies the function abs to the elements of solnum one by one. It is more or less equivalent to MATLAB's arrayfun(@abs, solnum)
回答 (1 件)
Walter Roberson
2025 年 1 月 24 日
移動済み: Walter Roberson
2025 年 1 月 24 日
You are plotting in Maple. MATLAB returns correct results.
syms x t
map(x,t) = 0.2e1 * (0.4e1 * exp((-8 * t + 2 * x)) + 0.9e1 * exp((-27 * t + 3 * x)) + 0.25e2 * exp((-35 * t + 5 * x + 2))) / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) - 0.2e1 * (0.2e1 * exp((-8 * t + 2 * x)) + 0.3e1 * exp((-27 * t + 3 * x)) + 0.5e1 * exp((-35 * t + 5 * x + 2))) ^ 2 / (exp(0.2e1) + exp((-8 * t + 2 * x)) + exp((-27 * t + 3 * x)) + exp((-35 * t + 5 * x + 2))) ^ 2;
fsurf(real(map), [-20 20 -5 5])
fsurf(imag(map), [-20 20 -5 5])
fsurf(abs(map), [-20 20 -5 5])
3 件のコメント
Walter Roberson
2025 年 1 月 24 日
All values produced by the function are already real values that are non-negative. The absolute value is therefore the same as the original values
Walter Roberson
2025 年 1 月 24 日
If solnum is the formula then when you map(abs, solnum) then you are applying abs() to the pieces of the formula rather than to the overall result of the formula.
Now, it looks to me as if each of the pieces of the formula should already be positive, but just maybe the map() is doing something like converting exp((-8 * t + 2 * x)) to exp(abs(-8 * t + 2 * x))
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




