loop through array of strings in tic
Mostra commenti meno recenti
Hi,
I want to loop through an array of strings in tlc that I retrieve from a MATLAB function.
I.e., something like the following: (OBS, this code doesn't work)
%assign values = FEVAL("my_fcn", arg)
%assign nbrOfValues = FEVAL("length", values)
%foreach i = nbrOfValues
%<values[i]>
%endforeach
How do I do this?
4 Commenti
Adam
il 9 Giu 2017
What is 'tlc' or 'tic'? It seems not to have anything to do with your code or I don't know what it stands for anyway.
Do you already have your array of strings (either a cell array of chars or actual string objects)?
If so then just
for n = 1:numel( myStrings )
myStrings{n} % Do whatever you want with the string
end
Rik
il 9 Giu 2017
It look like you would benefit from a crash course on Matlab. Your example code is not Matlab syntax, but it is very close to is, so why write it this way?
And whatever you do, try to find a way to solve your problem without having to resort to feval, eval or global variables. It is virtually always possible and virtually always a far superior piece of code.
Philip Borghesani
il 9 Giu 2017
Modificato: Philip Borghesani
il 9 Giu 2017
This is not MATLAB code it is tlc for the Target Language Compiler to create an S-function for use with Simulink and RTW.
Caroline Brandberg
il 3 Lug 2017
Risposte (0)
Categorie
Scopri di più su Target Language Compiler in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!