Azzera filtri
Azzera filtri

How to convert a structure int16 into a matrix?

4 visualizzazioni (ultimi 30 giorni)
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...

Risposta accettata

Stephen23
Stephen23 il 31 Ago 2018
Modificato: Stephen23 il 31 Ago 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:

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by