我们经常会遇到如图中的多个相似名称的多个文件,如何将这多个文件中的数据提取到同一个文件中,方便数据分析呢?
- matlab代码如下:
for i=0:20; %定义需要提取的文件数目
filename=strcat('no_1m.',num2str(i),'.csv'); %用i把文件名称相连
fid=csvread(filename,1,9,[1,9,1,9]); %定位需要提取的数据在文件中的坐标
M=fid/1000000; %对提取的数据进行操作
dlmwrite('without spray Uy.csv',M,'-append','precision',10); % 对提取的数据写入一个新的文件中
end
-
关于matlab中的
csvread
命令:
下面是一个csv文件中的内容,名称为csvlist
:
02, 04, 06, 08, 10, 12
03, 06, 09, 12, 15, 18
05, 10, 15, 20, 25, 30
07, 14, 21, 28, 35, 42
11, 22, 33, 44, 55, 66
- 读取整个数据集
m=csvread('csvlist.dat')
m =
2 4 6 8 10 12
3 6 9 12 15 18
5 10 15 20 25 30
7 14 21 28 35 42
11 22 33 44 55 66
- 从第3行,第1列开始读
m = csvread('csvlist.dat', 2, 0)
m =
5 10 15 20 25 30
7 14 21 28 35 42
11 22 33 44 55 66
- 读取一个区域
m = csvread('csvlist.dat', 2, 0, [2,0,3,3])
m =
5 10 15 20
MATLAB画函数图
%论文14拖曳系数图,图1,图2
ezplot('y1-0.16./[log(5302.7./x.^2)].^2=0',[0 4 10^-3 5*10^-3]);
hold on
ezplot('y2-((1-5.167*10^-2*x^2)*0.16./[log(5302.7./x.^2)].^2)=0',[0 4 10^-3 5*10^-3]);
grid on+
MATLAB设置图片大小
clear;
hold on;
x1=[27.3,33.1,40.8,50.8];
y1=[0.00193,0.00197,0.00193,0.00148];
scatter(x1,y1,'k');
hold on;
x2=[27.3,33.0,40.9,50.8];
y2=[0.00196,0.00215,0.00186,0.00150];
scatter(x2,y2,'+');
hold on;
x3=[27.9,32.7,39.7,49.8];
y3=[0.00146,0.00223,0.00260,0.00189];
scatter(x3,y3,'x');
hold on;
x4=[27.6,32.5,40.3,50.1];
y4=[0.00178,0.00244,0.00216,0.00173];
scatter(x4,y4,'d');
scatter(x1,y1,'k');
hold on;
scatter(x2,y2,'+');
hold on;
scatter(x3,y3,'x');
hold on;
scatter(x4,y4,'d');
set (gcf,'Position',[100,100,320,256]);%设置输出图片大小
set (gcf,'Position',[100,100,500,400]);