How can I simplify codes to combine multiple plots in one
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have 5 data files. Each of them include different timestamps, corresponding frequency range needs to distribute 4000 data points, and powder magnitude. I load 2 files as an example and be able to have basic codes to plot them into the same figure. One at beginning, and another one at the end. I am looking for advice to simply the codes. The 1200 and 1600 in the code represent the corresponding frequencies for each data file. Thanks.
Code to load data (Need to repeat these for different files):
Load Vehicle C_0727_1200 Data
filename_1200='Vehicle C_0727_1200.txt';
fid=fopen(filename_1200,'r');
for k=1:2;
tline=fgetl(fid);
end
data1200=zeros(4000,5562);
k=1;
while tline~=-1
datastr=regexp(tline,'(?<=">).*(?=<D)','match');
tempdata=textscan(datastr{1},'%f','delimiter',',');
data1200(:,k)=tempdata{1};
k=k+1;
tline = fgetl(fid);
end
Load Vehicle C_0727_1200 Timestamp
filename_1200='Vehicle C_0727_1200.txt';
fid=fopen(filename_1200,'r');
for k=1:2;
tline=fgetl(fid);
end
timestamp1200=zeros(1,5562);
t=1;
while tline~=-1
datestr=regexp(tline,'(?<=STime="20150727).*(?=" ETime)','match');
tempdata2=textscan(datestr{1},'%f');
timestamp1200(:,t)=tempdata2{1};
t=t+1;
tline = fgetl(fid);
end
fclose all;
Here is the code to generate the plot. These are just two files, so it shown the beginning part and end part of the figure attached.
Idx_1200=find (timestamp1200>=83419.000 & timestamp1200<90419.999); %Scenario 12: X = timestamp(8.3419<=timestamp(:,2)×tamp(:,2)<=9.0419,:);x=timestamp(:,1018:1944);
Idx_1600=find (timestamp1600>=83419.000 & timestamp1600<90419.999);
freqvec_1200=linspace(1150,1250,4000);
freqvec_1600=linspace(1550,1650,4000);
x1=timestamp1200(:,Idx_1200);
x2=timestamp1600(:,Idx_1600);
y1=freqvec_1200; %set freqvec with different linspace
y2=freqvec_1600;
z1=data1200(:,Idx_1200);
z2=data1600(:,Idx_1600);
%[X, Y]=meshgrid(x,y);
h1=surf(x1,y1,z1);
hold on
h2=surf(x2,y2,z2);
set(h1,'EdgeColor','none');
set(h2,'EdgeColor','none');
grid off
axis tight
view([90 90]); %Set view angle as Top-Flat 2D plot
colormap(jet);
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!