source: issm/oecreview/Archive/21337-21723/ISSM-21703-21704.diff@ 21726

Last change on this file since 21726 was 21726, checked in by Mathieu Morlighem, 8 years ago

CHG added Archive/21337-21723

File size: 1.5 KB
RevLine 
[21726]1Index: ../trunk-jpl/src/m/solve/WriteData.m
2===================================================================
3--- ../trunk-jpl/src/m/solve/WriteData.m (revision 21703)
4+++ ../trunk-jpl/src/m/solve/WriteData.m (revision 21704)
5@@ -173,9 +173,8 @@
6 %Get size
7 s=size(data);
8
9- if s(1)==1 | s(2)==1,
10- %No need to use Compressed format
11- error('Not needed (should call WriteData with DoubleMat)');
12+ if (s(1)==1 & s(2)==1 & isnan(data)),
13+ s(1)=0; s(2)=0;
14 end
15
16 %first write length of record
17@@ -191,19 +190,27 @@
18 fwrite(fid,s(1),'int');
19 fwrite(fid,s(2),'int');
20
21- %Write offset and range
22- A = data(1:end-1,:);
23- offset = min(A(:));
24- range = max(A(:)) - offset;
25- fwrite(fid,offset,'double');
26- fwrite(fid,range,'double');
27+ if s(1)*s(2),
28
29- %Convert data to uint8 and write it
30- A=uint8((A-offset)/range*255);
31- fwrite(fid,A','uint8'); %get to the "c" convention, hence the transpose
32+ %Write offset and range
33+ A = data(1:end-1,:);
34+ offset = min(A(:));
35+ range = max(A(:)) - offset;
36+ fwrite(fid,offset,'double');
37+ fwrite(fid,range,'double');
38
39- %Write last row as double (time)
40- fwrite(fid,data(end,:),'double');
41+ %Convert data to uint8 and write it
42+ A=uint8((A-offset)/range*255);
43+ fwrite(fid,A','uint8'); %get to the "c" convention, hence the transpose
44+
45+ %Write last row as double (time)
46+ fwrite(fid,data(end,:),'double');
47+ else
48+
49+ %Write empty offset and range
50+ fwrite(fid,0,'double');
51+ fwrite(fid,0,'double');
52+ end
53 % }}}
54 elseif strcmpi(format,'MatArray'), % {{{
55
Note: See TracBrowser for help on using the repository browser.