App designer - using a single variable to return multiple indices

Hi folks,
I am trying to pass two indices into a function but am currently failing as I'm sure I'm doing it wrong.
I tried to do this by defining an array, positionVector, which contains the indices I want to pass in pairs of 2, then using an iterator to pass these arguments to the function.
Is there a better way of doing this without hardcoding the positions?
Thanks
function ROI(app, index1, index2)
hold (app.Image, "on")
plot(app.Image, index1, index2, app.innerMarkerStyle, 'MarkerSize', app.CrosshairThickness.Value, 'Color', app.crossHairColour);
plot(app.Image, index1, index2, app.outerMarkerStyle, 'MarkerSize', app.CrosshairThickness.Value, 'Color', app.crossHairColour);
end
function DisplayCrosshairs(app)
I = imshow(app.currentImage, "Parent", app.Image);
app.Image.XLim = [0 I.XData(2)];
app.Image.YLim = [0 I.YData(2)];
app.Width = app.Image.XLim;
app.Height = app.Image.YLim;
quarterHeight = app.Height(1)+range(app.Height)*0.25;
halfHeight = app.Height(1)+range(app.Height)*0.5;
threeQuarterHeight = app.Height(1)+range(app.Height)*0.75;
quarterWidth = app.Width(1)+range(app.Width)*0.25;
halfWidth = app.Width(1)+range(app.Width)*0.5;
threeQuarterWidth = app.Width(1)+range(app.Width)*0.75;
positionVector = {quarterHeight quarterWidth; quarterHeight halfWidth; quarterHeight threeQuarterWidth; halfHeight quarterWidth; halfHeight halfWidth; halfHeight threeQuarterWidth; threeQuarterHeight quarterWidth; threeQuarterHeight halfWidth; threeQuarterHeight threeQuarterWidth};
checkMatrix = [app.TopLeft.Value app.TopMiddle.Value app.TopRight.Value app.CentreLeft.Value app.CentreMiddle.Value app.CentreRight.Value app.BottomLeft.Value app.BottomMiddle.Value app.BottomRight.Value];
app.numSamplesPerImage = sum(checkMatrix, 1:9);
for i = 1 : 9
if checkMatrix(i) == 1
ROI(app, positionVector{i});
end
end
end

 Risposta accettata

Change it as follows
ROI(app, positionVector{i,:}); %row i, all columns

Più risposte (0)

Prodotti

Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by