How do I create a vector with a string and an iterative counter
显示 更早的评论
I have a matrix filled with X and Y coordinates that I received from the contour function, that I am going to export to excel and then import into a 3D modeling program. However, I want to be able to name each point after the value of the contour curve and then numerically. (eg, for a curve with the value 600 I would name each point d_600.01, d_600.02, etc.) If I can make a vector with this I can slap it on top of my matrix and then export. Any thoughts?
5 个评论
Jan
2017-5-8
Don't do this. Do not hide indices in the names of variables. See http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval .
Stephen23
2017-5-8
@Jan Simon: I am not sure that Christopher Albert is trying to create variables in the workspace. The description seems to be a kind of header for exporting to an Excel workbook.
@Stephen: Maybe. "name each point after the value of the contour curve and then numerically" sounds like a mixture of data and naming scheme. "d_600.02" is not a useful header also for the same reasons why "d_600dot02" would be a bad name of a variable.
It is not clear to me, what "make a vector with this" means. @Christopher: Further explanations would be useful.
Christopher Albert
2017-5-9
@Chris, that's what I provided below...
% simplify one of doc contour plots to be small...
y = 0:0.2:2;x=y;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);
[C,hC]=contour(X,Y,1000*Z,'levellist',[100 200 300], ...
'showtext','on');
Apply algorithm below to above contour object/array yields following labels
>> [s(1:3);s(end-3:end)] % first/last three...
ans =
'100.01'
'100.02'
'100.03'
'300.07'
'300.08'
'300.09'
'300.10'
>>
for the contour plot above--

ADDENDUM Oh, the above is just the numeric level.point; to add a leading character just put it into the format statement...I'll modify Answer code...
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!