Warning: Integer operands are required for colon operator when used as index

4 ビュー (過去 30 日間)
Konstantinos
Konstantinos 2016 年 5 月 20 日
回答済み: Konstantinos 2016 年 5 月 20 日
I have a signal with multiple "pks4" points and I want to select only those elements which are between the first pks4 points - pks4(1) - until the end of the array xfb. So, I give the following command:
k2 = xfb(pks4(1):end)
But in the end I get the warning message "Integer operands are required for colon operator when used as index " about this line and no elements are included in the new k2 array. What is wrong?
Thank you in advance.
  4 件のコメント
Konstantinos
Konstantinos 2016 年 5 月 20 日
What are you talking about Guillaume?
Stephen23
Stephen23 2016 年 5 月 20 日
編集済み: Stephen23 2016 年 5 月 20 日
@Konstantinos: Guillaume asked for two very simple pieces of information that will help us to understand and answer your question. In particular:
mod(pks4(1), 1)
tells us if pks4(1) is really an integer. And
numel(xfb)
tells us how many elements xfb has. Both of these are important to understand your problem, even if you don't realize that. When you answer Guillaume's two requests for information then we know much more about your situation. Of course you do not have to give us this information: if you don't tell us then we will simply go outside for a beer in the afternoon sun.

サインインしてコメントする。

採用された回答

Konstantinos
Konstantinos 2016 年 5 月 20 日
Finally the problem was solved by converting the double values into integers using the int64 function.

その他の回答 (1 件)

Star Strider
Star Strider 2016 年 5 月 20 日
Doing my best to understand what you’re doing, you probably need to use a comparison test:
v = xfb(xfb >= pks4(1));
for k2 = 1:length(v)
execute...
end
Without your data this is only my best guess. It is obviously UNTESTED CODE.
  2 件のコメント
Konstantinos
Konstantinos 2016 年 5 月 20 日
編集済み: Konstantinos 2016 年 5 月 20 日
This couldn't work because my data come from electrograms, so they are unstable and they aren't stably increasing or decreasing. That means that I have both positive and negative values (and that's why the message refers to integers possibly). What I want to do is to pick those elements which are between pks4(1) -being the peak of the first electrogram at the recording - and the end of the array. So, what other solutions are there for my case?
Star Strider
Star Strider 2016 年 5 月 20 日
Without your data it’s difficult to tell.
I assume all your ‘pks4’ values are amplitude with respect to time, and time should be linearly increasing. So you have to find the index of that corresponding time value to ‘pks4(1)’, and then use those time indices to create the ‘v’ vector (in my example).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by