필터 지우기
필터 지우기

How to convert a structure int16 into a matrix?

조회 수: 4 (최근 30일)
maria
maria 2018년 8월 31일
편집: Stephen23 2018년 8월 31일
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...

채택된 답변

Stephen23
Stephen23 2018년 8월 31일
편집: Stephen23 2018년 8월 31일
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:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by