MATLAB Answers

How to get string field from struct with each element separated

조회 수: 12(최근 30일)
ans =
ans =
ans =
>> y = []
y =
I want to get it like that
y = ['1.33' '1.34' '1.35']
as a matrix with three string elements

  댓글 수: 0

Sign in to comment.

채택된 답변

gonzalo Mier
gonzalo Mier 11 May 2019
The problem is you are using char instead of string. '1.33' is a vector of char, so if you make a vector of vectors, it compiles them in a row. To make them string you can write "1.33" instead of '1.33' or string('1.33').

  댓글 수: 1

gonzalo Mier
gonzalo Mier 11 May 2019
for i= 1:length(x)
y(i) = string(x(i).name);

Sign in to comment.

추가 답변(0개)





Translated by