Syntax problem in creating a function which takes a vector as an argument
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
r_1 = 0.84 - 0.29i;
r_2 = 0.84 + 0.29i;
c = 4.55;
t = [2:1:50];
y(t) = k_1*r_1^t + k_2*r_2^t + c;
function out = t
out = [y(t)];
end
Hey! I have a syntax problem with my function:
I am trying to write a code which takes a vector [t_1,..,t_n] as an argument and returns a vector [y(t_1),...,y(t_n)]. Here you can see my function for now and the parameters which the function should have. How I should write the working code?
0 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 1 Feb. 2024
Bearbeitet: Dyuman Joshi
am 1 Feb. 2024
r_1 = 0.84 - 0.29i;
r_2 = 0.84 + 0.29i;
c = 4.55;
t = 2:1:50;
%Sample values for example
k_1 = 1;
k_2 = 2;
y = @(t) k_1*r_1.^t + k_2*r_2.^t + c;
out = y(t)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!