Borrar filtros
Borrar filtros

How to convert a structure int16 into a matrix?

4 visualizaciones (últimos 30 días)
maria
maria el 31 de Ag. de 2018
Editada: Stephen23 el 31 de Ag. de 2018
I am opening a variable (VAR) which is a structure and it contains inside 3 field which column of numbers (a,b,c) and 4th column (c) with a structure 700x4. I would like to work with c(:, 3), but by using the code
struct2array(VAR.C(:,3));
I obtain the error: Undefined function 'struct2cell' for input arguments of type 'int16' How to solve it?
str2double
also does not work...

Respuesta aceptada

Stephen23
Stephen23 el 31 de Ag. de 2018
Editada: Stephen23 el 31 de Ag. de 2018
You don't need to do anything extra, because this is already the numeric data that you want:
VAR.C(:,3)
VAR is a structure, so you could apply struct2cell to this, but there is no point for what you are doing. The field of a structure can be any class: numeric, cell, struct, function handle, ... In your case the field C is numeric, with class int16, so you don't need to apply any other functions to make it numeric... it already is numeric!
str2double would only make sense to apply if you have a character vectors, a string array, or a cell array of char vectors. You don't appear to have any of those in your data.
You should revise the basic data types, and how to access structure data:

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion 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