How can one define this variable in an elegant way?
3 次查看(过去 30 天)
显示 更早的评论
I want to define a variable x that is 300*1 vector. For the first 150 element, it is defined as an innerproduct of the first 150 element of a that is 300*1 and b that is 150*1. For the remaining 150 element, it will be defined by polyval(s1) of the remaining 150 element of a. I wrote
x=zeros(300,1)
for i=1:150
x(i,1)=a(i,1)*b(i,1)
end
for i=151:300
x(i,1)=polyval(s1,a(i,1))
end
But how can one write it in a more compact way?
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!