How can I take the first row of a cell array that contains doubles and insert it into the vector, without using the 'for' loop?
You can use curly braces to get entries from an array of cells as a comma-separated list , then collect these values ββin a row vector using square brackets. Here is an example:
>> C = num2cell(magic(5)) %# A sample cell array C = [17] [24] [ 1] [ 8] [15] [23] [ 5] [ 7] [14] [16] [ 4] [ 6] [13] [20] [22] [10] [12] [19] [21] [ 3] [11] [18] [25] [ 2] [ 9] >> vec = [C{1,:}] %# Put the first row in a vector vec = 17 24 1 8 15
Like this?
avector = cell2mat(acellarray(1,:));
Source: https://habr.com/ru/post/1303044/More articles:Could you explain this issue of removing C ++? - c ++Google like a dropdown when a user searches - c #How can you access the external contents of an iframe through DOM / Javascript? - javascriptA parameterized DB2 query from .NET. - c #Listing files in alphabetical order (both files and folders) - fileHow to access ViewData in javascript - c #How can I get Eclipse to store .class files in a folder outside the Project folder where I store the .java source files? - javaHow to store latitudes and longitudes in MySQL? - mysqlWhat HTTP status code should I return that tells the browser to stay on the current page? - htmlPretty Print / HTML Tidy for Google Web Toolkit (GWT)? - pretty-printAll Articles