problem with axes
problem with axes
(OP)
In the following example i am creating a figure and adding an axes to it. i want to do a quiver plot on the created axes. for this i am setting current axes to the created axes. But when i am calling quiver it is being plotted on a automatically created axes. please let me know what could be the problem.
h_figure = figure('Units','characters',...
'Position',[49.8000 13.4615 120.0000 35.0000],...
'Color',get(0,'DefaultUicontrolBackgroundColor'),...
'HandleVisibility','callback');
h_axes = axes('Units','characters',...
'Position',[10 4.5 72 26],...
'Parent',h_figure,...
'XLim',[-100,100],...
'YLim',[-100,100]);
strFilename = 'FOT024-03_FOT030-01_Jan_04';
% init file parameter
nHeaderLines = 12;
% open file channel
[fid,strMessage] = fopen(strFilename,'r');
% error handling
if fid < 1
disp(strMessage)
return
end
% loop over lines
iLine = 0;
iData = 0;
WNo = 0;
while ~feof(fid)
strLine=fgetl(fid);
iLine = iLine + 1;
% continue reading header
if iLine <= nHeaderLines, continue, end
% break if empty line
if isempty(deblank(strLine))
% break
if ~exist('data'), break, end
WNo = WNo+1;
TD(1,WNo)={data};
iLine = 1;
nHeaderLines = 9;
iData = 0;
clear data;
continue,
end
% data section
iData = iData + 1;
%example data line
%M0 2 1 7.833 -7.770 0.0113 -0.0163 PASS
% converting data line to numeric datatypes
try,
data(iData,1:6) = sscanf(strLine,'%*s %d %d %g %g %g %g %*s')';
catch,
break,
end
end
lineSpec=['-r';'-b']
for i=1:length(TD)
data = cell2mat(TD(i));
Wy=data(:,1);
Wy=data(:,2);
Gx=data(:,1)*26;
Gy=data(:,2)*32;
Sx=data(:,3);
Sy=data(:,4);
Dx=data(:,5);
Dy=data(:,6);
axes(h_axes)
% hold on;
quiver((Gx+Sx),(Gy+Sy),Dx,Dy,lineSpec(i,:))
end
fclose(fid);
h_figure = figure('Units','characters',...
'Position',[49.8000 13.4615 120.0000 35.0000],...
'Color',get(0,'DefaultUicontrolBackgroundColor'),...
'HandleVisibility','callback');
h_axes = axes('Units','characters',...
'Position',[10 4.5 72 26],...
'Parent',h_figure,...
'XLim',[-100,100],...
'YLim',[-100,100]);
strFilename = 'FOT024-03_FOT030-01_Jan_04';
% init file parameter
nHeaderLines = 12;
% open file channel
[fid,strMessage] = fopen(strFilename,'r');
% error handling
if fid < 1
disp(strMessage)
return
end
% loop over lines
iLine = 0;
iData = 0;
WNo = 0;
while ~feof(fid)
strLine=fgetl(fid);
iLine = iLine + 1;
% continue reading header
if iLine <= nHeaderLines, continue, end
% break if empty line
if isempty(deblank(strLine))
% break
if ~exist('data'), break, end
WNo = WNo+1;
TD(1,WNo)={data};
iLine = 1;
nHeaderLines = 9;
iData = 0;
clear data;
continue,
end
% data section
iData = iData + 1;
%example data line
%M0 2 1 7.833 -7.770 0.0113 -0.0163 PASS
% converting data line to numeric datatypes
try,
data(iData,1:6) = sscanf(strLine,'%*s %d %d %g %g %g %g %*s')';
catch,
break,
end
end
lineSpec=['-r';'-b']
for i=1:length(TD)
data = cell2mat(TD(i));
Wy=data(:,1);
Wy=data(:,2);
Gx=data(:,1)*26;
Gy=data(:,2)*32;
Sx=data(:,3);
Sy=data(:,4);
Dx=data(:,5);
Dy=data(:,6);
axes(h_axes)
% hold on;
quiver((Gx+Sx),(Gy+Sy),Dx,Dy,lineSpec(i,:))
end
fclose(fid);





RE: problem with axes
This might sound silly - and sorry if you've tried this already, but it looks like you have commented out the "hold on" command. Another thing you could try is replacing the semi colon after it with a comma, or removing it altogether.
Char