want to plot a function

1 Ansicht (letzte 30 Tage)
ting po chun
ting po chun am 30 Jul. 2024
Kommentiert: Star Strider am 30 Jul. 2024
Hi
I want to plot a function
and
the ref plot is
and now I code is
clc
clear
close all;
f=0:10:60;
tk=0.1;
tK=4;
theta0=-0.4;
theta1=0.3;
theta2=13.8/0.2;
for i=(0 0.1 40)
H=(theta0*(tK-tk))+(theta1*(exp(-theta2*tk*i)));
end
plot(f,H)
please help me how do i change my code to fix it?
ThankS

Akzeptierte Antwort

Star Strider
Star Strider am 30 Jul. 2024
Subscript ‘H’ in the loop, then create ‘f’ tto have the same size as ‘H’ and then plot —
fv = 0:10:60;
tk=0.1;
tK=4;
theta0=-0.4;
theta1=0.3;
theta2=13.8/0.2;
iv = 0 : 0.1 : 40;
for i = 1:numel(iv)
H(i) = (theta0*(tK-tk))+(theta1*(exp(-theta2*tk*iv(i))));
end
f = linspace(min(fv), max(fv), numel(H));
figure
plot(f,H)
grid
.
  2 Kommentare
ting po chun
ting po chun am 30 Jul. 2024
Thanks so much
Star Strider
Star Strider am 30 Jul. 2024
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by