to create a loop to assign names
4 views (last 30 days)
Show older comments
Hello,
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);
impixelinfo;
end
...
end
I will be grateful if you could help me
Thank you
Answers (1)
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;
showInputName(x)
showInputName(1:10) % The input has no name
function showInputName(~)
fprintf("The name of the input argument is %s\n", inputname(1))
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!