MATLAB: How to count number of pcwrite when I want to save file

for looppcwritepoint cloud

I have a problem about pcwrite .
when I use for-loop to save the file .ply extension name , I have problem that name can't use num2str to save the file
example
such as I want to save files
pcwrite (plane, 'Plane 1', 'PLYFormat', 'binary');
And
pcwrite (plane, 'Plane 2', 'PLYFormat', 'binary');
but I don't want to input integer to filename as mentioned.
And I tried
pcwrite (plane, 'Plane num2str (loop)', 'PLYFormat', 'binary');
But it not work.
please help me to fix this.
sorry for my English isn’t that good.
but I hope that you will understand me.
thanks for help

Best Answer

better to use sprintf:
str = sprintf('Plane %d',loop);
pcwrite (plane, str, 'PLYFormat', 'binary');
or using num2str:
str = ['Plane ',num2str(loop)];
pcwrite (plane, str, 'PLYFormat', 'binary');
You can find very clear explanations and examples in the MATLAB documentation:
and on this forum: