How can I convert data of 2 cells into one vector?
3 次查看(过去 30 天)
显示 更早的评论
I have this for loop:
min = zeros(1,4);
max = zeros(1,4);
vector = zeros(1,4);
for i = 1:4
min(1,i) = min(time{1,i});
max(1,i) = max(time{1,i});
vector(1,i) = [min(1,i); max(1,i)]; % I tried this but it does not work
end
I want to create a matrix with on the first place a vector with [min(1,1); max(1,1)] and on the second place a vector [min(1,2); max(1,2)] ,... So in each cell of the matrix I want a vector of 2 numbers.
Can someone help me? Thanks!
0 个评论
回答(1 个)
Jan
2020-12-21
Do not use the names of the built-in functions "min" and "max" as names of variables, because this causes troubles frequently.
[min(1,i); max(1,i)] is a [2 x 1] vector, but vector(1,i) is a scalar. You cannot assign a vector to a scalar. Maybe you want:
vector = zeros(2, 4);
...
vector(:, i) = [min(1,i); max(1,i)];
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!