将结构数组转换为双精度数组 [英] Convert the struct array into double array

查看:210
本文介绍了将结构数组转换为双精度数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将7位患者的数据组合在一起,每个数据包含19个特征,如下所示.现在,数据采用具有19个字段的7x1结构.

I have combined 7 patients' data, each containing 19 features, into one struct as seen below. The data is now in a 7x1 struct with 19 fields.

我需要怎么做才能将结构转换为双精度数组?我需要将其用作SVM分类器的输入.或有关如何将患者数据直接保存到双数组而不是结构中的任何建议.

What do I need to do to convert the struct to a double array? I need to use it as input for an SVM classifier. Or any suggestions for how to save the patients' data directly into a double array not a struct.

在此处输入图片描述

推荐答案

使用struct2array:

% generating struct
dataStruct = struct;
[dataStruct(1:5).a] = deal(rand,rand,rand,rand,rand);
[dataStruct(1:5).b] = deal(rand,rand,rand,rand,rand);
[dataStruct(1:5).c] = deal(rand,rand,rand,rand,rand);
% convert it to matrix
data = reshape(struct2array(dataStruct),[],numel(dataStruct))';

这篇关于将结构数组转换为双精度数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆