I want to draw the previous point Delete the next point

5 visualizzazioni (ultimi 30 giorni)
%__________________________ This is to return to the previous point
app.i=app.i-1;
if app.i>1
addpoints(app.hnext,app.Cent_Viloc(app.i).Center(1),app.Cent_Viloc(app.i).Center(2))
text(app.UIAxes,app.Cent_Viloc(app.i).Center(1)+0.2,app.Cent_Viloc(app.i).Center(2)+0.2,...
[num2str(app.i),"Volocity : ",num2str(app.Cent_Viloc(app.i).Velocity(1))],"FontSize",10,"FontWeight",...
"bold","Color",'y',...
'BackgroundColor',[1 1 1])
drawnow
end
%__________________________ This is to go to the next point
app.i=app.i+1;
if app.i>1
addpoints(app.hnext,app.Cent_Viloc(app.i).Center(1),app.Cent_Viloc(app.i).Center(2))
text(app.UIAxes,app.Cent_Viloc(app.i).Center(1)+0.2,app.Cent_Viloc(app.i).Center(2)+0.2,...
[num2str(app.i),"Volocity : ",num2str(app.Cent_Viloc(app.i).Velocity(1))],"FontSize",10,...
"FontWeight","bold","Color",'white',...
'BackgroundColor',[0.6 0.2 0.5])
drawnow
end
  5 Commenti
Amir Azadeh Ranjbar
Amir Azadeh Ranjbar il 20 Ago 2022
Thank you very much for your advice
If I could do it in any other way
I will definitely post the method here
dpb
dpb il 20 Ago 2022
Modificato: dpb il 20 Ago 2022
Unfortunately, TMW has removed a lot of the previous documentation illustrating these things -- they think animatedline is supposed to be all anybody should ever need -- the only existing example I find in current doc is <trace-marker-along-line>, but it does illustrate the technique of updating the plot handle data directly.
The Q? in your case is what is supposed to happen between points when delete one -- although I guess it's a case of only going back a single step at a time?

Accedi per commentare.

Risposta accettata

dpb
dpb il 20 Ago 2022
Modificato: dpb il 21 Ago 2022
I had not poked at an animatedline object with Yair Altman's FEX submission to find hidden properties, but it turns out the X|YData arrays are pre-allocated (looks like begins with 5,000 by default) and buried several layers deep, but accessible if you know the magic decoder ring password...
Try this to get the idea and then you can adapt to your app variables, needs...
hAL=animatedline('Marker','o'); % create object, keep handle
xlim([0 1]);ylim([0 1]) % keep limits fixed so doesn't autorange on us
hold on
for i=1:5 % add some points...
addpoints(hAL,i/10,rand)
pause(0.5)
end
pause(0.5)
for i=hAL.NumPointsAdded:-1:1 % now we'll remove them in reverse order
hAL.NodeChildren.Children.XData(hAL.NumPointsAdded)=nan; % convert so won't display
hAL.NodeChildren.Children.YData(hAL.NumPointsAdded)=nan;
hAL.NumPointsAdded=hAL.NumPointsAdded-1; % update the point count to match
pause(0.5)
end
Supercially, this seems to work; what other issues may arise by munging on the object through undocumented, hidden properties only experimentation will uncover.
NOTA BENE: The X|YData arrays are initialized to zero in the object properties but no zero point is displayed initially until a specific entry at the origin were to be made via addpoints. But, in the above setting the value back to zero even though the number of points is also decremented results in the zero showing as a point at the origin; hence the use of NaN to take advantage of the builtin feature of HG that only finite values are rendered. Somewhere internally is other logic that "knows" the difference between zeros that were initial values and uses some other indicator besides only 'NumPointsAdded' to render only the first N points, but I didn't find what the key indicator is in this short investigation into the internals.
If it works to serve your purposes, well and good; but if it crashes and burns, you're on your own to figure out why and if can work around it. And, of course, just because it might work now doesn't mean the next release won't change something that breaks it.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by