How to find positive and negative outputs?
10 ビュー (過去 30 日間)
Hi, I'm trying to have a= dif<-100 or dif>100 with dif being the difference between two numbers, but having trouble getting the negative values to work.
I currently have it as
dif=struct.smth(:,10) - struct.smth(:,i)
num = (dif <-100) | (100 < dif);
I have also tried
but still only get the positive values to work.
The output when the negative number is triggered is "0x1 empty double column vector"
dpb 2022 年 5 月 10 日
編集済み: dpb 2022 年 5 月 10 日
" negative number is triggered is "0x1 empty double column vector"
It's always possible there ARE no values such that struct.smth(:,10) - struct.smth(:,i) < -100 in which case the empty vector is the expected result.
You need to always remember to write your code when using find and other functions which have such variable-number of outputs where, in fact, one of the valid results is that the result is NIL.
Often placing such code within the try...catch portion and the fixup code for the empty case in the catch...end portion of a try, catch block construct is a slick way to deal with the issue. It may be that the catch block is empty; there's nothing to do in that case.
ixG100 = find(abs(struct.smth(:,10) - struct.smth(:,i)) >100);
will find both cases; you can determine which easily enough when processing the results might be another way to approach it.
I didn't look at all at what really trying to do; just generic comments...
その他の回答 (0 件)
Find more on Fast Fourier Transforms 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!