如何迭代Matlab表的列? Python等价物和假设数据是熊猫数据框将是:
mainStore
但是对应的Matlab表不起作用:
variable_names=data.keys() #get variable names
for i in variable_names: # iterate over and print all data using variable names
print data[i]
答案 0 :(得分:2)
此代码应该可以解决问题
% generate some random table with 100 rows
entry = table(rand(100,1),randi(100,100,1),cellstr(char(randi([65,90],100,5))));
% extract the var names
var = entry.Properties.VariableNames;
% now for each column display the contents in three different ways
% obviously you could do whatever you like with the data
for ii=var
disp(entry.(ii{1})(1:4));% display only the first 4 entries
disp(entry.(ii{1})(:)');% display all the entries as a row
disp(entry.(ii{1})(end-4:end));% display only the last 4 entries
end
享受