Use of Evalin
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
for i=1:str2num(get(handles.nosensorentry_tag,'string'))
set(handles.sensname(i),'string',evalin('base','SensorList.sensorname(i,1)'))
end
I am not able to use loop to get the workspace variable with evalin. Matlab is showing
Error using ==> evalin
Subscript indices must either be real positive integers or logicals.
Is there any way to increment 'i' in evalin statement.
0 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Abr. de 2012
names = evalin('base', 'SensorList.sensorname');
for i = 1:str2num(get(handles.nosensorentry_tag,'string'))
set(handles.sensname(i), 'String', names(i,1));
end
0 comentarios
Más respuestas (2)
Daniel Shub
el 25 de Abr. de 2012
You need to evaulate the i in the current workspace and not the base:
for i=1:str2num(get(handles.nosensorentry_tag,'string'))
set(handles.sensname(i),'string',evalin('base', ...
['SensorList.sensorname(', num2str(i), ',1)']))
end
0 comentarios
Jan
el 25 de Abr. de 2012
n = str2num(get(handles.nosensorentry_tag,'string'))
for i = 1:n
set(handles.sensname(i), 'string', SensorList.(sensorname{i}));
end
1 comentario
Walter Roberson
el 25 de Abr. de 2012
I believe the idea is that SensorList is defined in the base workspace but not the current workspace.
Ver también
Categorías
Más información sobre Get Started with MATLAB 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!