I have a struct array field seg.startscan. I want to erase some of its elements.
For example the elements corresponding to the indices stored contained in an array INDS.
The followings are ny try and the relative errors:
1)
seg.startscan(INDS) = [ ];
??? Scalar structure required for this assignment.
2)
seg(INDS).startscan = [ ];
??? Insufficient outputs from right hand side to satisfy comma separated list expansion on left hand side. Missing [] are the most likely cause.
3)
startscans = seg.startscan; startscans(INDS) = [ ]; fldnm = 'startscan'; seg.(fldnm) = startscans;
??? Insufficient outputs from right hand side to satisfy comma separated list expansion on left hand side. Missing [] are the most likely cause.
4)
startscans = seg.startscan; startscans(INDS) = [ ]; fldnm = 'startscan'; [seg.(fldnm)] = startscans;
??? Too many output arguments.
5) as suggested here: 1:
>>startscans = seg.startscan;
startscans(INDS) = [ ];
fldnm = 'startscan';
[seg.(fldnm)] = startscans;
??? Too many output arguments.
Do you have any ideas? Probably I do not grasp the idea behind the struct arrays..
Let's say that my input is:
>>seg.startscan
ans=
1
ans=
2
ans=
3
ans=
4
>>INDS = [1 3];
then my expected output is:
>>seg.startscan
ans=
2
ans=
4
This gave a quite similar solution, but it not vectorized and not completely right
>>for i = 1:numel(INDS)
seg(IND(i)).startscan=[];
end
>>seg.startscan
ans=
[]
ans=
2
ans=
[]
ans=
4
Help please!
Thank you!
INDS, with all their fields. Does the struct array have more fields other thanstartscan?seg(1)with only fieldstartscanandseg(1)with fieldsstartscanandstopscan. You need to delete all fields ofseg(1). Or fill with empty: eitherseg(1).startscan = [];or[seg(IND).startscan] = deal([])