MATLAB Answers

SS
0

Expected one output from a curly brace or dot indexing expression, but there were 2 results.

Asked by SS
on 13 Aug 2019
Latest activity Commented on by SS
on 4 Oct 2019 at 8:31
Hi.I working with a code to manipulate some data and here are the lines which gives error
S12(m).x2(n)=S2(tn4).x(ts4) % line 104
S12(m).dx2(n)=S2(tn4).dx(ts4) % line 105
S12(m).z(n)=S2(tn4).y(ts4) % line 106
The error is,
Expected one output from a curly brace or dot indexing expression, but there were 2 results.
Error in data_man (line 104) S12(m).x2(n)=S2(tn4).x(ts4)
How can I fix this error?

  3 Comments

Could you attach the missing datas as a .mat file?
Here is the data file, I renamed the Newtracks as S2 in the following code. The error is in line 104
S12(m).x2(n)=S2(tn4).x(ts4) % line 104
S12(m).dx2(n)=S2(tn4).dx(ts4) % line 105
S12(m).z(n)=S2(tn4).y(ts4) % line 106

Sign in to comment.

1 Answer

Answer by Bruno Luong
on 13 Aug 2019
Edited by Bruno Luong
on 13 Aug 2019

In general you are not allow to assign multi-level structures with non-scalar indexing in one shot, you need to do in 2 steps.
% S12(m).x2(n)=S2(tn4).x(ts4)
x2 = {S12(m).x2};
x = {S2(tn4).x};
for k=1:length(x2)
x2{k}(n) = x{k}(ts4);
end
[S12(m).x2] = deal(x2{:});

  1 Comment

I have tried your suggestion and it results in follwoing error:
Reference to non-existent field 'x2'.
I am unable to resolve the error since, x2 is already defined.

Sign in to comment.