Borrar filtros
Borrar filtros

How to put the output of a function into a struct?

4 visualizaciones (últimos 30 días)
Sam
Sam el 25 de Dic. de 2014
Respondida: Image Analyst el 25 de Dic. de 2014
I'm given the following function to read files into Matlab:
function [VideoSignals,VideoSignals_headers,AnalogSignals,AnalogSignals_headers,AnalogFrameRate,VideoFrameRate] = read_c3d_file(fullFileName)
I want to put the output 'VideoSignals, VideoSignals_headers, AnalogSignals, AnalogSignals_headers, AnalogFrameRate and VideoFrameRate' immediately into a struct. How do I do this?
  3 comentarios
Sam
Sam el 25 de Dic. de 2014
I want to put the 6 outcomes of the function into a struct (cell 1x1).
Image Analyst
Image Analyst el 25 de Dic. de 2014
structures and cells are different things. See the FAQ http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F Which do you want? I think structures are easier if you have a choice.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 25 de Dic. de 2014
Just assign them:
sa.VideoSignals = VideoSignals;
sa.VideoSignals_headers = VideoSignals_headers;
sa.AnalogSignals = AnalogSignals;
sa.AnalogSignals_headers = AnalogSignals_headers;
sa.AnalogFrameRate = AnalogFrameRate;
sa.VideoFrameRate = VideoFrameRate;
You can add indexes to sa if you want to make it a structure array.
sa(k).VideoSignals = VideoSignals;
sa(k).VideoSignals_headers = VideoSignals_headers;
sa(k).AnalogSignals = AnalogSignals;
sa(k).AnalogSignals_headers = AnalogSignals_headers;
sa(k).AnalogFrameRate = AnalogFrameRate;
sa(k).VideoFrameRate = VideoFrameRate;
You can have one index, like k, or two or three or however many you need.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by