
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)的所有信息 展开
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)的所有信息 展开
1个回答
2016-05-29 · 知道合伙人软件行家
关注

展开全部
你定义结构体的方法不对,具体你可以参考我给你的程序。
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询