Repmat converts '' to []

조회 수: 3 (최근 30일)
Aditya Jain
Aditya Jain 2015년 10월 30일
댓글: Aditya Jain 2015년 11월 11일
I want to create an array of structs
I am using the following code
structElement = struct('a', '', 'b', '', 'c', []);
ans = repmat(structElement, [4,1]);
The problem is that repmat converts '' to []
I want it to be ''
Is there a better way to do this?
  댓글 수: 1
Aditya Jain
Aditya Jain 2015년 10월 30일
This happens only when I see it in Workspace Browser/ Viewer by double clicking a. Doesn't happen if I do ans(1,1).a
So probably a bug in Workspace browser?

댓글을 달려면 로그인하십시오.

채택된 답변

Nitin Khola
Nitin Khola 2015년 11월 3일
Thanks for bringing this to the fore. At this instance, this appears to be an issue with the variable editor and not "repmat". You have mentioned that in the comment and it can also be illustrated by:
>> structElement = struct('a', '', 'b', '', 'c', []);
>> RepSt = repmat(structElement, [4,1]);
>> ischar(RepSt(1,1).a)
ans =
1
>> ischar(RepSt(1,1).c)
ans =
0
I was able to reproduce this issue. I will add it to our records. On a side note, I would like to request you to not use "ans" as a variable. Using the reserved keywords as variable and function names should be avoided.
  댓글 수: 1
Aditya Jain
Aditya Jain 2015년 11월 11일
was just using that to reproduce the issue. Thanks for the tip :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by