フィルターのクリア

Is it my equation wrong? Cause I get a weird graph for this equation.

1 回表示 (過去 30 日間)
Muhammad Harriz Bin Zamri
Muhammad Harriz Bin Zamri 2022 年 6 月 2 日
回答済み: Voss 2022 年 6 月 2 日
clear; clc;
syms t;
f=exp(-2*t)*tanh(4*t);
c=0.000009;
I=c*diff(f);
figure(1); fplot(I); grid; xlabel('time'); ylabel('current'); title('current vs time');

採用された回答

Voss
Voss 2022 年 6 月 2 日
If the current is given by that function of time i(t), and you should plot the current vs time, then there is no need to do c*diff(f) (not for part A anyway).
Also, specify a time interval in fplot that starts at 0.
syms t; I=exp(-2*t)*tanh(4*t); %c=0.000009; I=c*diff(f);
figure(1); fplot(I,[0 5]); grid; xlabel('time'); ylabel('current'); title('current vs time');

その他の回答 (2 件)

Sam Chak
Sam Chak 2022 年 6 月 2 日
Missing dot.
t = 0:0.01:5;
x = exp(-2*t).*tanh(4*t);
plot(t, x, 'linewidth', 1.5)
xlabel('t')
ylabel('i(t)')
grid on

Image Analyst
Image Analyst 2022 年 6 月 2 日
You may need to specify a time vector rather than use syms. Like
t = linspace(0, 5, 500);
f=exp(-2*t).*tanh(4*t);
c=0.000009;
I=c*diff(f);
figure(1);
plot(t(2:end), I, 'b-', 'LineWidth', 2);
grid;
xlabel('time');
ylabel('current');
title('current vs time');

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by