Reloading handle objects from .mat files
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Why does isequal() return false when the reloaded handle is compared to the original handle, in the code below.
h=plot(1:5);
save tst h
h2=load('tst').h;
isequal(h,h2)
0 commentaires
Réponse acceptée
Paul
le 27 Mai 2023
Hi Matt,
It looks like two of the properties are changed, either on the save or on the load.
h=plot(1:5);
save tst h
h2=load('tst').h;
isequal(h,h2)
p = properties(h);
for ii = 1:numel(p)
if ~isequal(h.(p{ii}),h2.(p{ii}))
p{ii}
h.(p{ii})
h2.(p{ii})
disp(' ')
end
end
I guess it makes sense for the Parent property to not be saved because it might not be in existence on the reload?
Not sure what's not isequal between the DataTipTemplates. Didn't drill down into DataTipRows
0 commentaires
Plus de réponses (1)
Walter Roberson
le 26 Mai 2023
f1 = figure(1);
ax1 = axes('Parent', f1);
h1 = plot(ax1, 1:10);
save tst f1
h1.YData(end) = 5
datastruct = load('tst');
f2 = datastruct.f1;
isequal(f1, f2)
f1.Number
f2.Number
double(f1)
double(f2)
f1.Children(1).Children(1).YData
f2.Children(1).Children(1).YData
Now, under your hypothesis, f1 (the live figure handle) should isequal() f2 (the retrieved saved version of the figure handle). But if they are isequal() then how would you account for the fact that the YData for the two needs to be different, since the plot for f1 was modified after it was saved? Should the retrieved copy have been updated to reflect the changes to f1, or should the active f1 have been regressed to reverse the changes so as to match the restored figure handle?
Or is it your position that when we modified the YData underneath the first figure, that the handle f1 should itself have changed?
5 commentaires
Voir également
Catégories
En savoir plus sur Test and Measurement dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!