imagesc does not take an axis handle as its first argument even if it should
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alec Poulin
el 19 de Sept. de 2018
Comentada: Alec Poulin
el 20 de Sept. de 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 comentarios
Respuesta aceptada
Steven Lord
el 19 de Sept. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!