简体   繁体   中英

How to copy cell to array in Matlab

Alright let me explain detailed my question

this below image is displaying my matrix where i want to copy my data

在此处输入图片说明

Alright now what i want to do that is as you can see 1x4 cell i want to copy it as an array to another variable such as

    input_values=ones(1,4);%init
    input_values=input_matrix_training(1);

So at the above i am trying to copy the elements in that cell array which is row 1 to the input_values array. But if i do as i above i am getting this instead of the values that array contains. ty

在此处输入图片说明

instead of above it should be like

在此处输入图片说明

The other values are a cell, and are thus best referenced with {} instead of () . Also, sometimes they need to be wrapped into [] , depending on the format. Plus the fact that you don't need to initialize input_values, and what you should do becomes this:

input_values=[input_matrix_training{1}];

Or you can just use cell2mat

input_values=cell2mat(input_values(1));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM