matlab结构数组数据提取

%生成投资者账号1investor.account=[1:1000]';%投资者账户可用资金量2investor.available_funds=10^4*rand(10... %生成投资者账号1
investor.account=[1:1000]';
%投资者账户可用资金量2
investor.available_funds=10^4*rand(1000,1);
%账户持仓量3
investor.open_interest=10^4*rand(1000,1);
%账户总资金量4
investor.capital=10^4*rand(1000,1);
这个M文件用不用function定义 怎么定义
怎么提取investor(51)的所有信息
展开
 我来答
木生子识时务
2016-05-29 · 知道合伙人软件行家
木生子识时务
知道合伙人软件行家
采纳数:455 获赞数:1968
现在浙江大学学习,对电脑网络,软件应用有过全面系统的学习。

向TA提问 私信TA
展开全部

你定义结构体的方法不对,具体你可以参考我给你的程序。

clear;

account = [1:1000];
%把数值数组转换为胞元数组
account = num2cell(account)';
%投资者账户可用资金量2
available_funds = 10^4*rand(1000,1);
available_funds = num2cell( available_funds );
%账户持仓量3
open_interest = 10^4*rand(1000,1);
open_interest = num2cell( 10^4*rand(1000,1) );
%账户总资金量4
capital = 10^4*rand(1000,1);
capital = num2cell( capital );

%创建结构体
investor = struct( 'account', account, 'available_funds',available_funds, 'open_interest',open_interest, 'capital',capital);

investor(51)

 结果为(随机结果,不会一样):

ans = 

            account: 51
    available_funds: 7.3542e+03
      open_interest: 1.7649e+03
            capital: 3.2393e+03
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式