How to get data from 2D array and put into 1D array

后端 未结 3 408
眼角桃花
眼角桃花 2021-01-27 14:44

I have a 2D array and I want to create a 1D by MATLAB, satisfying the requirement that each element of the 1D output was created by the value of a given index into the 2D array.

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-27 15:38

    I am not sure I understand your question but i think you want to apply functions on a 2-by-n matrix

    Try

    for pos=1:size(a,2)
      b(pos) = f(a(:,pos));
    end
    

提交回复
热议问题