フィルターのクリア

Exceeds the number of array elements (0).

2 ビュー (過去 30 日間)
Neda Deljavan
Neda Deljavan 2023 年 1 月 24 日
編集済み: Voss 2023 年 2 月 7 日
Hi everyone,
I have got the error in the code below, What should I do to fix it?
Code
% convert finite values to indices between 1 and map length
n = size(map, 1);
inds = (img(valid)-bounds(1))/(bounds(end)-bounds(1))*(n-1);
inds = floor(min(max(inds, 0), n-1))+1;
Error
Index exceeds the number of array elements (0).
Error in double2rgb (line 44)
ins = (img(valid)-bounds(1))/(bounds(end)-bounds(1))*(n-1);

採用された回答

Voss
Voss 2023 年 1 月 24 日
Either img or bounds (or both) is empty.
Check img and bounds and figure out why one or both is not what you expect.
  9 件のコメント
Neda Deljavan
Neda Deljavan 2023 年 2 月 7 日
After the section above, for running code below I've got an error, what's the problem?
Code:
for ll = 1 : length(links) %% plotting links
line([EEG.chanlocs(links(ll,1)).X, EEG.chanlocs(links(ll,2)).X], [EEG.chanlocs(links(ll,1)).Y, EEG.chanlocs(links(ll,2)).Y], 'LineWidth', wij(ll), 'Color', rgb(ll,:) );
end
colormap(jet);
% colorbar
for nn = 1 : 4 %% plotting nodes
plot(EEG.chanlocs(nn).X, EEG.chanlocs(nn).Y, 'ro', 'MarkerSize', st(nn), 'MarkerFaceColor', 'y')
text(EEG.chanlocs(nn).X+0.5, EEG.chanlocs(nn).Y, EEG.chanlocs(nn).labels, 'FontSize', 11);
end
view([270 90]); %% rotating to vertical view
axis equal; axis off;
set(gcf, 'units','normalized','outerposition',[0 0 1 1]) %EXPANDING FIGURE ON SCREEN
Error:
Error using line
Value should be a finite number greater than 0
Error in NEW1 (line 452)
line([EEG.chanlocs(links(ll,1)).X, EEG.chanlocs(links(ll,2)).X], [EEG.chanlocs(links(ll,1)).Y, EEG.chanlocs(links(ll,2)).Y], 'LineWidth', wij(ll),
'Color', rgb(ll,:) );
Thanks in advance for your help.
Bests,
Neda
Voss
Voss 2023 年 2 月 7 日
編集済み: Voss 2023 年 2 月 7 日
My guess is that wij(ll) is NaN or Inf or a non-positive number.
You can see below that those cases throw the error you got:
try
line([1 2],[1 2],'LineWidth',NaN)
catch e
delete(gca())
disp(e.message);
end
Value should be a finite number greater than 0
try
line([1 2],[1 2],'LineWidth',Inf)
catch e
delete(gca())
disp(e.message);
end
Value should be a finite number greater than 0
try
line([1 2],[1 2],'LineWidth',0)
catch e
delete(gca())
disp(e.message);
end
Value should be a finite number greater than 0
try
line([1 2],[1 2],'LineWidth',-1)
catch e
delete(gca())
disp(e.message);
end
Value should be a finite number greater than 0

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by