Syntax problem in creating a function which takes a vector as an argument
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Dyuman Joshi
2024-2-1
编辑:Dyuman Joshi
2024-2-1
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!