Syntax problem in creating a function which takes a vector as an argument
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Dyuman Joshi
il 1 Feb 2024
Modificato: Dyuman Joshi
il 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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!