Unable to perform assignment because the size of the left side is 1-by-201 and the size of the right side is 200-by-1

1 回表示 (過去 30 日間)
Soeun Lee
Soeun Lee 2021 年 7 月 20 日
編集済み: Voss 2024 年 2 月 15 日
Hello, I would like to change my prePeak and posPeak value from 0.0005 to 1/fs(which is the sampling frequency 24414)*100. However when I change the prePeak and posPeak value to 1/fs*100, I get the error message "Unable to perform assignment because the size of the left side is 1-by-201 and the size of the right side is 200-by-1". Any suggestion on how I should modify the code?
Thanks!
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 7 月 21 日
If you are certain that you will have a constant number of entries (201) for each time range, then it usually makes more sense to reshape() than to do the kind of looping you are doing.
I notice you are using a closed interval. If there happened to be any point that is exactly at one of the interval boundaries, then that point would be included in two different intervals, which would throw off the assumption of constant number of points per interval.

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

回答 (1 件)

Jan
Jan 2021 年 7 月 20 日
編集済み: Jan 2021 年 7 月 20 日
Replace:
ts = -prePeak:1/fs:posPeak;
by
ts = linspace(prePeak, postPeak, 201);
But as far as I can see, you use ts only to measure its length. Then simply omit the definition and replace "length(ts)" by "201".
I'm not sure where the "201" is coming from, but I cannot know, why neural.spikes(S) has 201 elements.
  5 件のコメント
Feng Du
Feng Du 2024 年 2 月 15 日
Did you fix it? I meet the same question, I don't know how to fix it.
Voss
Voss 2024 年 2 月 15 日
編集済み: Voss 2024 年 2 月 15 日
@feng du: It's impossible to say how to fix this problem without seeing your code and data. I suggest you open a new question and share your code and data there.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by