Search code examples
matlabcsvmatrixcell

Copying cell matrix values to new matrix MATLAB


I have 60 values in a cell matrix from a .csv file which are stored in column 15 from rows 38556-38616

I want to copy that range of values to a regular numerical 60x1 matrix in a variable Value

Here is what I tried:

Values(60,1) = data2{38556:38616,15};

It only copies 1 value from data2 and the rest of values from rows 1-59 are 0. How can I copy those values to Value in the same order they are in the file? data2 is the cell matrix storing .csv file values.

Image of data2:

enter image description here


Solution

  • Either

    Values(1:61,1) = cell2mat(data2(38556:38616,15));
    

    or just

    Values = [data2{38556:38616,15}]';
    

    The problem was that you tried to store 61 values into just one matrix element.