Syntax problem in creating a function which takes a vector as an argument
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jenni
el 1 de Feb. de 2024
Comentada: Jenni
el 1 de Feb. de 2024
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 comentarios
Respuesta aceptada
Dyuman Joshi
el 1 de Feb. de 2024
Editada: Dyuman Joshi
el 1 de Feb. de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!