How to create new variables in batches with strcat

31 visualizaciones (últimos 30 días)
TingTing
TingTing el 9 de Abr. de 2015
Editada: Stephen23 el 19 de Jun. de 2019
Hi,
What I want to do is something like
for m=1:11
for i=1:3
for k=1:5
for x=1:9
strcat(InputCell{m,1},'_', InputCell{1,i},'_',InputCell{m,i}{k},'_',InputCell{m,i}{k,2}{x}) = xlsread(filename,'strcat(InputCell{m,1},'_', InputCell{1,i},'_',InputCell{m,i}{k})', 'InputCell{m,i}{k,2}{x}')
end
end
end
end
Where strcat () creates a bunch of new variable names and xlsread reads the corresponding sheet and range... but strcat can only create string text, how can I let Matlab take that as new variable?
And I suppose the xlsread part also doesn't work as it is now... just let you guys know what I am thinking of ...
Thanks a lot!

Respuesta aceptada

Stephen23
Stephen23 el 9 de Abr. de 2015
Editada: Stephen23 el 19 de Jun. de 2019
  8 comentarios
xian zhao
xian zhao el 15 de En. de 2018
At the begainning, I declare a variable whose name will change as above. However, it's suggest as explain above.
Walter Roberson
Walter Roberson el 15 de En. de 2018
Simulink itself is not able to use variable names that change like that. You would have to be using something like a tunable parameter and set_param() calls if you were trying to use something like that, and there is simply no reason to want to do so when you could instead use a fixed variable and change its value instead of the name.
If you are trying to do this in a MATLAB Function block that is referenced by Simulink, there there is no hope that it could work except when Acceleration was completely off. For any other Acceleration, Simulink needs to compile to blocks (at least partly) and that compilation cannot use dynamic variable names.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by