Error using scatter3. Incorrect number of inputs for property-value pairs.

72 views (last 30 days)
Hey guys. I'm writing a code which has to plot 3d values on a 2d grid. I've succeeded in doing this for another (different) data set. However for this data set i keep getting the same error in using scatter3. I've looked up the error but it hasn't helped me (I could only find one other person with a similar error).
The code I'm using is as follows:
x=[];y=[];ssc=[];
for j=1:length(files)
fid = fopen([datdir files(j).name],'rt');
for p=1:10
tmp=fgetl(fid);
end
for i=1:200
for j=1:2
tmp=fgetl(fid);
end
if ~ischar(tmp)
break
end
x=tmp(14:22);
y=tmp(24:33);
for j=1:4
tmp=fgetl(fid);
end
C=textscan(fid,'%f %f');
ssc=[ssc;mean(C{2})];
ssc(ssc>=500)=0.001;
S=repmat([4],length(ssc),1);
C=repmat([1-ssc/100,1-ssc/100,1-ssc/100],1,1);
scatter3(x,y,ssc,S,C)
end
fclose(fid);
end
The error derives at the scatter3 line and is: Error using scatter3 (line 45) Incorrect number of inputs for property-value pairs.
The x, y and ssc components in the scatter3 function all have the same amount of values (1 in this case), so that cant be the problem.
A sample of the data file being processed:
[if true]
*------------------------------------------
* Type : ViSea DPS Type III ASCII file.
* Source : ViSea DPS © Aqua Vision BV
* Name : ADCP data 'MV2_120331_006r.asc'
* Position : moving RDV
* Date : 20120331 7:54 - 20120331 7:58 LOCAL
*
* column 1 : depth below water surface (m)
* column 2 : sediment concentration (mg/l)
*------------------------------------------
*
* Position : 58251.195 443538.687 x/y RDV
* Date : 20120331 075412 LOCAL
*
B0001
5 3
0.75 14.4
1.00 14.4
1.25 12.2
1.50 6.7
1.75 3.7
*
* Position : 58252.436 443539.652 x/y RDV
It would be awesome if someone would be able to tell me how to manipulate my code in order to get around this error. Thanks in advance!

Answers (1)

Guillaume
Guillaume on 3 Mar 2015
Edited: Guillaume on 4 Mar 2015
In your code, I see
x=tmp(14:22);
y=tmp(24:33);
where
tmp = fgetl(fid);
Therefore your x and y are char arrays (you can check with whos x, y). Possibly you missed a str2num in your assignment to x and y. That would be consistent with scatter3 thinking you're trying to pass property values pairs (i.e. strings + value).
Personally, I'd parse your file with:
fid = fopen(fullfile(datdir, files(j).name),'rt'); %use path concatenation function
tline = fgetl(fid); %tmp is a very meaningless variable name
while ischar(tline) && ~strncmp(tline, '* Position : ', numel('* Position : '))
tline = fgetl(fid);
end
if ~ischar(tline)
error('end of file reached prematurely')
end
position = str2double(regexp(tline, '(?<=\s+)\d+\.\d+', 'match')); %no hardcoding of the number position!
x = position(1); y = position(2);
for skiplines = 1:4
if ~ischar(fgetl(fid))
error('end of file reached prematurely')
end
end
data = textscan(fid,'%f %f');

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!