''Unable to perform assignment because the left and right sides have a different number of elements.''
3 views (last 30 days)
Show older comments
tolerance=0.002; %SETTLING TIME CALCULATE
t=fdev(:,1);
f1=abs(fdev(:,2));
f2=abs(fdev(:,3));
tie=abs(ptie(:,2));
ts=zeros(1,3);
ts(1)=t(max(find(f1>=tolerance)));
ts(2)=t(max(find(f2>=tolerance)));
ts(3)=t(max(find(tie>=tolerance)));
Ts=sum(ts);
it is showing "Unable to perform assignment because the left and right sides have a different number of elements."Why is this happening?
0 Comments
Answers (1)
dpb
on 26 Feb 2020
ts(1)=t(max(find(f1>=tolerance)));
and friends can return an empty RHS if no element satisfies the condition.
2 Comments
dpb
on 26 Feb 2020
Well, doesn't matter which of the three it is, the same symptom is possible.
What do you want the result to be if there are no elements of tie that are >= tolerance?
You could wrap the line in a try...catch block to ignore and go on which would leave the LH side zero for which ever element(s) did fail.
Or, maybe the problem stems from the fact the variable tie isn't what you think it is? Have you used debugger to see what is actually going on?
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!