integral caculation using matlab
1 回表示 (過去 30 日間)
古いコメントを表示
I don't know what's error in my code. Could you give me some advice?
x = (10^-5:10^1);
y = 0.453 .* exp(-1.036 .* x) .* sinh((2.29.* x).^0.5);
sym m
m = int(y, x, 0.0625, inf);
semilogx(x,y)
hold on
semilogx(x,m)
0 件のコメント
回答 (1 件)
Aditya
2023 年 1 月 25 日
編集済み: Aditya
2023 年 1 月 25 日
Hi, I understand that you are getting error when running the above script. The reason why you are getting an error is because int expects the expression, y to be symbolic.
To solve this, you need to create x as a symbolic variable. Change the line `x = (10^-5:10^1);` to `syms x;`
For running your full script, you also need to modify how the script is plotting. Here is how you can modify your scipt to use semilogx:
syms x;
y = 0.453 * exp(-1.036 * x) * sinh((2.29* x)^0.5);
m = int(y, x, 0.0625, inf);
x_i = (10^-5:10^1);
y_i = zeros(numel(x_i),1);
m_i = zeros(numel(x_i),1);
for i = 1:numel(x_i)
y_i(i) = subs(y,x,x_i(i));
m_i(i) = subs(m,x,x_i(i));
end
figure;
semilogx(x_i,y_i)
semilogx(x_i,m_i)
For plotting symbolic variables, however, fplot is used. Here is how the script would look like with fplot:
syms x;
y = 0.453 * exp(-1.036 * x) * sinh((2.29* x)^0.5);
m = int(y, x, 0.0625, inf);
figure;
fplot(x,y);
hold on;
fplot(x,m);
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!