HOW TO READ A .WRL FILE IN MATLAB?

12 次查看(过去 30 天)
Ampi
Ampi 2020-11-19
Dear Sir,
I have written the following code to read a 3D .wrl file in MATLAB.
for i= 1:61
filename1=strcat(path1,strcat(a,int2str(i)));
filename=strcat(filename1,'_');
filename1=strcat(filename1,b(i));
filename1=strcat(filename1,'.wrl');
vrfile=fopen(filename1);
end
path1 is defined earlier as path1='D:\'
but when I am running the code I am geeting the following error:-
Error using fopen
First input must be a file name of type char, or a file
identifier of type double.
Error in Readobj_Gavabdb (line 27)
vrfile=fopen(filename1);
But instead of filename1 if i write 'D:\gavaDB\cara1_abajo.wrl' the program is running.
Please somebody tell me how to make the above code run. Kindly mail me at :- paramabagchi@gmail.com

回答(1 个)

Cris LaPierre
Cris LaPierre 2020-11-19
The most obvious error I see is that you change the varialbe name when you append the '_'. You save that result to filename. You then use filename1 in the next line, which means the underscore is not appearing in your final result.
You might want to consider using the function fullfile to create filename1. You can do it in a single line of code, and it will handle adding the slashes, etc. for you.
for i=1
filename1 = fullfile("D:","gavaDB",["cara" + num2str(i) + "_" + "abajo" + ".wrl"])
end
filename1 = "D:/gavaDB/cara1_abajo.wrl"

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by