forked from noobmartin/Open-source-SAR-simulator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_simulation_data.m
66 lines (49 loc) · 1.5 KB
/
plot_simulation_data.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function plot_simulation_data()
delimiter = '\t';
% Open up and parse dimensions file.
fp = fopen('dimensions.dat');
if(fp == -1)
disp(strcat('Could not open dimensions.dat for reading - exiting.'));
return;
end
while( ~feof(fp) )
% Read file descriptor and size.
name = fgetl(fp);
rows = str2num(fgetl(fp));
cols = str2num(fgetl(fp));
% Ignore empty matrices.
if(rows < 1)
continue;
end
if(cols < 1)
continue;
end
% Read file as a matrix.
fname = strcat(name, '.dat');
rimg = dlmread(fname, delimiter);
if(cols == 1)
img = zeros(1,rows);
rvect = 1:rows;
img(1,rvect) = rimg(2*rvect-1)+rimg(2*rvect)*1i;
figure('Name', name, 'NumberTitle', 'Off');
title(name);
plot(abs(img));
xlabel('Time samples');
ylabel('Amplitude');
elseif(cols >= 2)
r = rows;
c = cols;
cols = r;
rows = c;
img = zeros(rows, cols);
cvect = 1:cols;
rvect = 1:rows;
img(rvect, cvect) = rimg(rvect,2*cvect-1)+rimg(rvect,2*cvect)*1i;
figure('Name', name, 'NumberTitle', 'Off');
imagesc(cvect,rvect,abs(img));
title(name);
xlabel('Range (m)');
ylabel('Azimuth (m)');
end
end
fclose(fp);