can i give variable different names then call this name

1 次查看(过去 30 天)
hi guys
please I have question in displaying a name in matlab. I am using 5 cases each one has its won properties. after finishing the calculation I want to display the material name with the output data. is there any way to give a variable the name of material in every case so I can call it in the display or fprintf function.
Best regards

采纳的回答

Matt J
Matt J 2012-11-29
Sure. You can even pass it several names, e.g.,
material={'lead','silver','gold'};
for ii=1:3, disp(material{ii}), end

更多回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-11-29
You can also generate names depending on your counter
for k=1:3
name{k}=sprintf('name%d',k)
end

Walter Roberson
Walter Roberson 2012-11-29

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by