フィルターのクリア

How to code equation

5 ビュー (過去 30 日間)
Cesar Cardenas
Cesar Cardenas 2023 年 1 月 24 日
回答済み: Nisar 2024 年 5 月 15 日
Hello, just wondering if this equation could be coded like this:
Any feedback will be greatly appreciated. Thanks
m = 10e-3
a = 0.05
c = 0.1
x(t) = m/a e^-(c/a)t

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 1 月 24 日
A couple of small errors have been corrected:
m = 10e-3;
a = 0.05;
c = 0.1;
x = @(t)(m/a)*exp(-(c/a)*t);
t = linspace(0,1.3);
plot(t, x(t))
xlabel('t')
ylabel('x(t)')
grid on
  1 件のコメント
Cesar Cardenas
Cesar Cardenas 2023 年 1 月 27 日
Thanks much for your help. I added another equation and would like to know how to plot both on the same graph? not sure about it. Thanks
m = 10e-3;
a = 0.05;
c = 0.1;
x = @(t)(m/a)*exp(-(c/a)*t);
x = @(t)(m/a)*1-exp(-(a/m)*t);
t = linspace(0,1.5);
plot(t, x(t))
xlabel('t')
ylabel('x(t)')
grid on

サインインしてコメントする。

その他の回答 (3 件)

Torsten
Torsten 2023 年 1 月 24 日
移動済み: Torsten 2023 年 1 月 24 日
m = 10e-3;
a = 0.05;
c = 0.1;
x = @(t) m/a*exp(-c/a*t);
t = 0:0.01:2;
plot(t,x(t))
  1 件のコメント
Cesar Cardenas
Cesar Cardenas 2023 年 1 月 27 日
Thanks much for your help. I added another equation and would like to know how to plot both on the same graph? not sure about it. Thanks
m = 10e-3;
a = 0.05;
c = 0.1;
x = @(t)(m/a)*exp(-(c/a)*t);
x = @(t)(m/a)*1-exp(-(a/m)*t);
t = linspace(0,1.5);
plot(t, x(t))
xlabel('t')
ylabel('x(t)')
grid on

サインインしてコメントする。


Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 1 月 27 日
Put both functions in plot() command or use hold on:
m = 10e-3;
a = 0.05;
c = 0.1;
x1 = @(t)(m/a)*exp(-(c/a)*t);
x2 = @(t)(m/a)*1-exp(-(a/m)*t);
t = linspace(0,1.5);
plot(t, x1(t), 'r-', t, x2(t), 'b-.', 'linewidth', 2)
xlabel('$t$', 'Interpreter', 'latex')
ylabel('$x(t)$', 'Interpreter', 'latex')
legend('$x_1(t)$', '$x_2(t)$','Interpreter', 'latex', 'location', 'SE')
grid on
%% Alternative solution:
m = 10e-3;
a = 0.05;
c = 0.1;
x1 = @(t)(m/a)*exp(-(c/a)*t);
x2 = @(t)(m/a)*1-exp(-(a/m)*t);
figure
fplot(x1, [0, 1.5], 'r-', 'linewidth', 2)
hold on
fplot(x2, [0, 1.5], 'b-.', 'linewidth', 2)
xlabel('$t$', 'Interpreter', 'latex')
ylabel('$x(t)$', 'Interpreter', 'latex')
legend('$x_1(t)$', '$x_2(t)$','Interpreter', 'latex', 'location', 'SE')
grid on
  1 件のコメント
Cesar Cardenas
Cesar Cardenas 2023 年 2 月 3 日
Hello, thanks much for your response, really useful. Now, I'm trying to code these equations. This is my attempt. I would like to plot Cf vs x/L, but x/L as I have it shows me an error..the same with delta/x, not sure why? any help will be greatly appreciated. Thanks much.
Re = 0:500:1000;
x/L = 0:0.2:1;
Cf = 0.664*(Re)^-0.5;
delta/x = 5.0*(Re)^-0.5;

サインインしてコメントする。


Nisar
Nisar 2024 年 5 月 15 日
clc;
T=10;
Fs=1;
t=-2*T:1/(10*Fs):2*T;
rect_pulse_fft = fftshift(fft(rect_pulse));
L=length(t);
f=Fs*(-L/2:(L/2-1))/L;
rect_pulse_fft=fftshift(fft(rect_pulse));
subplot(2,1,1);
plot(t,rect_pulse);
xlabel('Time(s)');
ylabel('Amplitude');
title('time Domain Representation of Rectangular pulse');
subplot(2,1,2);
plot(f,abs(rect_pulse_fft));
xlabel('frequency(Hz)');
ylabel('Magnitude');
title('frequemcy domain representation of rectangular pulse');

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by