assign empty vector to an element of a vector in a for loop
2 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I created a 'for' loop with 'solve'
for i0=1:1:length(sig)
syms r
r0(i0)=double(solve(function_of_r,r));
end
At some points, the 'solve' function returns '0×1 empty double column vector' (which is correct).
But then, Matlab returns an error 'Unable to perform assignment because the left and right sides have a different number of elements.' because of the empty vector.
I understood the problem but is there any way to assign that empty vector to an element of another vector?
I would like to have the vector in the form like r=[1, 3 , 4 ,[], [], [],..., 5, 7,9]
Thanks
0 个评论
采纳的回答
Star Strider
2019-6-10
One option could be to assign it instead as a cell array:
r0{i0} = ..
.Note the curly brackets {}.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!