Azzera filtri
Azzera filtri

Reading existing function in MATLAB?

1 visualizzazione (ultimi 30 giorni)
Saurav il 23 Apr 2024
Commentato: Cris LaPierre il 23 Apr 2024
I have download some function of Matlab for my project work. Now when I am running that function then it is showing error
Error: >> stlRead
Execution of script stlRead as a function is not supported:
I:\Python coding\3d\New findings\vsangelidakis\vsangelidakis-SHAPE-f97791a\lib\stlTools\stlRead.m
Error in stlRead (line 1)
[v, f, n, name] = stlRead('aggregate_1.stl');
I am attcahing the folder of the function.

Risposta accettata

Cris LaPierre
Cris LaPierre il 23 Apr 2024
Modificato: Cris LaPierre il 23 Apr 2024
The issue is that your function name is strReads, not stlRead. However, it is best practice to use the same name for the function and the file. You function is actually called stlGetFormat. You should rename your file so that it has the same name as your function, and use that name to call it.
type stlReads.m
function format = stlGetFormat(fileName) %STLGETFORMAT identifies the format of the STL file and returns 'binary' or %'ascii' fid = fopen(fileName); % Check the file size first, since binary files MUST have a size of 84+(50*n) fseek(fid,0,1); % Go to the end of the file fidSIZE = ftell(fid); % Check the size of the file if rem(fidSIZE-84,50) > 0 format = 'ascii';
You can learn more about creating functions in MATLAB here:
  1 Commento
Cris LaPierre
Cris LaPierre il 23 Apr 2024
Incidentally, MATLAB has an stlread function.
TR = stlread('aggregate_1.stl')
TR =
triangulation with properties: Points: [13535x3 double] ConnectivityList: [27066x3 double]

Accedi per commentare.

Più risposte (0)


Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by