effective way of transformation from 2D to 1D vector
问题 i want to create 1D vector in matlab from given matrix,for this i have implemented following algorithm ,which use trivial way % create one dimensional vector from 2D matrix function [x]=one_dimensional(b,m,n) k=1; for i=1:m for t=1:n x(k)=b(i,t); k=k+1; end end x; end when i run it using following example,it seems to do it's task fine b=[2 1 3;4 2 3;1 5 4] b = 2 1 3 4 2 3 1 5 4 >> one_dimensional(b,3,3) ans = 2 1 3 4 2 3 1 5 4 but generally i know that,arrays are not good way to use in matlab