imagesc does not take an axis handle as its first argument even if it should
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alec Poulin
le 19 Sep 2018
Commenté : Alec Poulin
le 20 Sep 2018
According to the documentation (https://www.mathworks.com/help/matlab/ref/imagesc.html), imagesc should take as an optional first argument an axis handle. However, I get errors when I try this:
fig = figure;
ax = fig.CurrentAxes;
imagesc(ax, [1,2;3,4])
The output is this:
>> test
Dot indexing is not supported for variables of this type.
Error in imagesc (line 48)
elseif any(strcmpi(cax.NextPlot,{'replaceall','replace'}))
Error in test (line 3)
imagesc(ax, [1,2;3,4])
Using a much bigger script, I also got the following error, which I am unable to reproduce with a short script:
Error using image
Incorrect number of arguments.
Error in imagesc (line 40)
hh = image(varargin{:},'CDataMapping','scaled');
Error in testbed2_generateF (line 93)
imagesc(ax, [N_BS(1), N_BS(end)], [N, N], log10(errF))
0 commentaires
Réponse acceptée
Steven Lord
le 19 Sep 2018
Look at the variable ax.
>> fig = figure;
ax = fig.CurrentAxes
ax =
0×0 empty GraphicsPlaceholder array.
That's not an axes. When you create a figure, it doesn't have an axes on it unless you've specifically set up a CreateFcn or something similar that adds an axes. [When you call a plotting function like plot it creates the figure then creates an axes on that figure and finally creates the plot on the axes.] Compare with:
>> fig = figure;
axes(fig);
ax = fig.CurrentAxes
ax =
Axes with properties:
...
The error message could probably stand to be a bit more descriptive. If you feel strongly about that, I recommend submitting that to Technical Support as an enhancement request using the Contact Us link in the upper-right corner of this page.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Programming 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!