Effacer les filtres
Effacer les filtres

How to convert a structure int16 into a matrix?

4 vues (au cours des 30 derniers jours)
maria
maria le 31 Août 2018
Modifié(e) : Stephen23 le 31 Août 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...

Réponse acceptée

Stephen23
Stephen23 le 31 Août 2018
Modifié(e) : Stephen23 le 31 Août 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:

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by