Index exceeds matrix dimensions Error

1 回表示 (過去 30 日間)
Cory Morales
Cory Morales 2015 年 6 月 29 日
コメント済み: Cory Morales 2015 年 6 月 29 日
Hello
I am trying to access data from a document and the data gets imported correctly. The array for data is a 20 x 20 size array, but when I try to access row 2, it gives the index exceeds matrix dimensions error.
Here is my code:
figure(1);
markers=['+' 'o' '*' '.' 'x' 's' 'd' '^' 'v' '<' '>' 'p' 'h'];
location = 1;
disp(size(data()));
for i=1:num_trials
for j=1:num_sensors
col = 5 + (j-.5) * 2;
plot(location * ones(size(data(:,col,i))),data(:,col,i),'.'); hold on;
end
location = location+1;
end
grid on;
The specific line generating the error is: plot(location * ones(size(data(:,col,i))),data(:,col,i),'.'); hold on;

採用された回答

James Tursa
James Tursa 2015 年 6 月 29 日
If "data" is 20x20, why are you indexing into it as a 3D array? E.g.,
data(:,col,i)
What are the values of num_trials and num_sensors? That could be another source of problems.
  7 件のコメント
James Tursa
James Tursa 2015 年 6 月 29 日
If class(data) returns 'double', what does the phrase "struct with fields that are cell arrays that contain double arrays" mean specifically?
Cory Morales
Cory Morales 2015 年 6 月 29 日
Actually, I think it works now. Thanks!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by