How can I convert data of 2 cells into one vector?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Jan
le 21 Déc 2020
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 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!