在matlab中从每100次迭代中找出最大行
我已创建一个mat文件:在matlab中从每100次迭代中找出最大行,matlab,Matlab,我已创建一个mat文件: S = load abc.mat S = data1: [81x30 double] data2: [59x28 double] data3: [20x28 double] 加载这个mat文件后,我使用这个mat文件运行一些代码,结果显示在命令窗口中,如下所示 disp([Ball Trial A B C D]) 30.0000 1.0000 0.4498 0.3652 0.4601 0.3777 30.0000
S = load abc.mat
S = data1: [81x30 double]
data2: [59x28 double]
data3: [20x28 double]
加载这个mat文件后,我使用这个mat文件运行一些代码,结果显示在命令窗口中,如下所示
disp([Ball Trial A B C D])
30.0000 1.0000 0.4498 0.3652 0.4601 0.3777
30.0000 2.0000 0.5745 0.5006 0.5671 0.4940
...
30.0000 99.0000 0.5209 0.4420 0.5112 0.4311
30.0000 100.0000 0.4078 0.4142 0.3974 0.4060
35.0000 1.0000 0.4303 0.3563 0.4083 0.3356
35.0000 2.0000 0.5239 0.4469 0.5174 0.4396
...
35.0000 99.0000 0.6009 0.5442 0.5985 0.5410
35.0000 100.0000 0.5327 0.4756 0.5037 0.4503
...
100.0000 99.0000 0.3015 0.3273 0.3027 0.3287
100.0000 100.0000 0.4416 0.3960 0.4533 0.4088
第一列是从30号球到100号球(30:5:100),第二列是100次迭代,然后第三、第四、第五和第六列是A、B、C、D的结果
[c t] = max(max(C.'));% variable c is the max of C in each ball (index) t.
我想画一个线图,包括每个索引(球)中的最大c…其中x轴是t(球30到100),y轴是变量c…我可以知道如何绘制吗
并在.txt文件中显示每个索引(球)上的最大c行
结果:def.txt
30.000 23.000 0.23 0.45 0.76 0.32
35.000 19.000 0.43 0.67 0.23 0.54
...
100.000 43.000 0.54 0.11 0.54 0.99
有人能帮我绘制图表并获取def.txt吗?谢谢……这是我的工作
??? 索引超过了矩阵维度。在10 y(:,col)=accumarray(yIdx,S(:,col+2),[],@max)下测试时出错==>@noob:使用
data
代替S,其中data=[Ball-Trial A B C D]代码>
%# data is the content of abc.mat
load('abc.mat')
%# find x, corresponding indices into y
[x,~,yIdx] = unique(data(:,1));
%# in each column, collect the maximum for each yIdx
y = zeros(length(x),4);
for col=1:4
y(:,col) = accumarray(yIdx,data(:,col+2),[],@max);
end
%# plot
ph=plot(x,y);
set(ph,{'DisplayName'},{'A';'B';'C';'D'})
legend()
%# save result to file
dlmwrite('def.txt', [x y])