How can i use linkaxes with multiple imshow in appdesigner?

5 views (last 30 days)
I wanna show all three layers of an RGB (or other color spaces) image and link them together with the original image to perform treshold operations with some spinner or slider. This is what i've tried so far:
properties (Access = private)
ax0 matlab.graphics.axis.Axes
ax1 matlab.graphics.axis.Axes
ax2 matlab.graphics.axis.Axes
ax3 matlab.graphics.axis.Axes
end
%reading image
[file,path]=uigetfile('*','Load');
filename=sprintf('%s%s',path,file);
filename = convertCharsToStrings(filename);
I = imread(filename);
%layers with max and min
I1=I(:,:,1); I1_down=min(min(I1)); I1_up=max(max(I1));
I2=I(:,:,2); I2_down=min(min(I2)); I2_up=max(max(I2));
I3=I(:,:,3); I3_down=min(min(I3)); I3_up=max(max(I3));
imshow(I,'Parent',app.UIAxes_tot); %original img
imshow(I1,[I1_down I1_up],'Parent',app.UIAxes_1); %1st layer
imshow(I2,[I2_down I2_up],'Parent',app.UIAxes_2); %2nd layer
imshow(I3,[I3_down I3_up],'Parent',app.UIAxes_3); %3rd layer
app.ax0 = axes(app.UIAxes_tot);
app.ax1 = axes(app.UIAxes_1);
app.ax2 = axes(app.UIAxes_2);
app.ax3 = axes(app.UIAxes_3);
linkaxes([app.ax0,app.ax1,app.ax2,app.ax3]);
this is the error:
Error using axes
Too many output arguments.
(line 56)
app.ax0 = axes(app.UIAxes_tot);
what is the problem?

Accepted Answer

Benjamin Kraus
Benjamin Kraus on 27 Dec 2020
linkaxes only started working with UIAxes in MATLAB R2020b.
  • If you are using an older release and you cannot upgrade, I recommend switching from using UIAxes to regular axes. Regular axes have worked in App Designer since MATLAB R2018b, but you have to create them programmatically using the axes command (rather than dragging and dropping them when designing your app).
  • If you are using MATLAB R2020b, this code is unnecessary and is what is causing the problem:
app.ax0 = axes(app.UIAxes_tot);
app.ax1 = axes(app.UIAxes_1);
app.ax2 = axes(app.UIAxes_2);
app.ax3 = axes(app.UIAxes_3);
linkaxes([app.ax0,app.ax1,app.ax2,app.ax3]);
All you should need is this:
linkaxes([app.UIAxes_tot,app.UIAxes_1,app.UIAxes_2,app.UIAxes3]);

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by