''Unable to perform assignment because the left and right sides have a different number of elements.''
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
dpb
2020-2-26
ts(1)=t(max(find(f1>=tolerance)));
and friends can return an empty RHS if no element satisfies the condition.
2 个评论
dpb
2020-2-26
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!