【发布时间】:2018-01-15 21:56:29
【问题描述】:
我有代码可以根据存储在多个 .csv 文件中的数据生成二维图:
clearvars;
files = dir('*.csv');
name = 'E_1';
set(groot, 'DefaultLegendInterpreter', 'none')
set(gca,'FontSize',20)
hold on;
for file = files'
csv = xlsread(file.name);
[n,s,r] = xlsread(file.name);
des_cols = {'Stress','Ext.1(Strain)'};
colhdrs = s(2,:);
[~,ia] = intersect(colhdrs, des_cols);
colnrs = flipud(ia);
file.name = n(:, colnrs);
file.name = file.name(1:end-500,:);
plot(file.name(:,2),file.name(:,1),'DisplayName',s{1,1});
end
ylabel({'Stress (MPa)'});
xlabel({'Strain (%)'});
title({name});
legend('show');
我想做的是修改代码,以便将由 .csv 数据制作的 2D 图连接成 3D 图,其中一个轴是 files 中的 .csv 索引,有点像图片在这个post 的顶部。我从那篇帖子中得到了使用plot3 的想法,但我不确定如何让它发挥作用。
据我了解,我需要创建 3 个新矩阵 xMat, yMat, zMat。每个矩阵的列包含来自 csv 文件的数据,yMat 包含的列只是 csv 的索引,但我不完全确定从这里去哪里。
感谢您的帮助!
【问题讨论】:
-
你应该看看这个问题和我的回答,和你的问题很相似:How can I plot several 2D image in a stack style in Matlab?
-
谢谢,但@aero-engy 的回答更符合我的要求