"Invalid handle." Error while using "Plot3".

2 ビュー (過去 30 日間)
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 9 日
回答済み: Walter Roberson 2017 年 6 月 9 日
ax = axes('Parent',customUserInterface,'Position',[.1 .5 .375 .4]);
hold on
for m=1:numOfAP
plot3(ax,Data(m).traj(:,1),Data(m).traj(:,2),Data(m).traj(:,3),'g','LineWidth',2)
hold on
grid on
end
hold on
The Error points to the line with "Plot3". What am I going wrong with? Thanks in advance.
  5 件のコメント
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 9 日
@walterRoberson
I checked the code once again but I do not have a "clear all" or "close all" anywhere in the code. I am putting down the code for your ref. Please suggest some work around. Thanks in advance.
customUserInterface = figure('Name','Solution selector window');
ax = axes('Parent',customUserInterface,'Position',[.1 .5 .375 .4]);
hold on
% to plot all the crossing points
subplot(ceil(sqrt(size(sectors_all,1))),ceil(sqrt(size(sectors_all,1))),p, 'Position',flightDataPlotPosition);
hold on;
if isempty(CP_xyz) == 0
plot3(ax,CP_xyz(:,1),CP_xyz(:,2),CP_xyz(:,3),'rh','LineWidth',2);
end
hold on
% To plot the trajectory taken by all the flights in the current hour
for m=1:numOfAP
plot3(ax,Data(m).traj(:,1),Data(m).traj(:,2),Data(m).traj(:,3),'g','LineWidth',2)
hold on
grid on
end
hold on
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 9 日
編集済み: Abhay Aradhya 2017 年 6 月 9 日
Found out that the "subplot" is the culprit. And without that it works fine. Any idea of a workaround?

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 9 日
subplot() removes any axes that it overlaps. Your subplot() has exactly the same Position as your axes() call, so the subplot axes is going to overlap the explicit axes() created, which will cause the specific axes to be deleted.

その他の回答 (1 件)

KSSV
KSSV 2017 年 6 月 9 日
You should proceed like this.
h = plot3(rand(1,2),rand(1,2),rand(1,2),'g','LineWidth',2) ;
grid on
for m=1:100
set(h,'XData',rand(1,2),'YData',rand(1,2),'ZData',rand(1,2)) ;
end
  2 件のコメント
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 9 日
編集済み: Abhay Aradhya 2017 年 6 月 9 日
customUserInterface = figure('Name','Solution selector window');
ax = axes('Parent',customUserInterface,'Position',[.1 .5 .375 .4]);
hold on
subplot(ceil(sqrt(size(sectors_all,1))),ceil(sqrt(size(sectors_all,1))),p, 'Position',[.1 .5 .375 .4]);
hold on;
h = plot3(ax,rand(1,2),rand(1,2),rand(1,2),'g','LineWidth',2) ;
grid on
for m=1:numOfAP
set(h,'XData',Data(m).traj(:,1),'YData',Data(m).traj(:,2),'ZData',Data(m).traj(:,3))
end
hold on
Tried the above approach to no avail the same error exists...!!!
It shows error at "plot3" again. Without the "ax" it seems to be working fine though, but I do need the referencing in my case as I am trying to plot 2 3D graphs on the same GUI. Please suggest any other solution. Thanks in advance
Abhay Aradhya
Abhay Aradhya 2017 年 6 月 9 日
編集済み: Abhay Aradhya 2017 年 6 月 9 日
Found out that the "subplot" is the culprit. And without that it works fine. Any idea of a workaround?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by