to create a loop to assign names

4 views (last 30 days)
Tugce Irem
Tugce Irem on 21 Aug 2022
Commented: Tugce Irem on 21 Aug 2022
I'm analyzing multiple images at the same time, and in my function multiple different figures show different features. I wanted to create a code to determine each individual' specific name. here is my code to name the figures. This is not entire function but I only need to learn how to change the name. I don't know what I should write the line of k=
function AnalyzeImage(originalImage, lowThreshold, highThreshold)
fontSize = 14;
for k= [originalImage]
figure(k); imagesc(originalImage); colormap(gray(256));
title(k, 'FontSize', fontSize);
I will be grateful if you could help me
Thank you

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 21 Aug 2022
If you're just using this to obtain the name of the variable in the workspace from which your function was called, use inputname but make sure to include some code to handle the case where the input argument doesn't have a name.
x = 1:10;
The name of the input argument is x
showInputName(1:10) % The input has no name
The name of the input argument is
function showInputName(~)
fprintf("The name of the input argument is %s\n", inputname(1))

Community Treasure Hunt

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

Start Hunting!