フィルターのクリア

how to rectify the error Index exceeds matrix dimensions.?

1 回表示 (過去 30 日間)
prajwal prabhu
prajwal prabhu 2017 年 4 月 27 日
編集済み: Torsten 2017 年 4 月 27 日
i am doing real time plotting of my sensor output in matlab. How to rectify the above error.This is my code.
if true
clc
clear all
close all
a=arduino('com13','uno');
a1_pin='D9';
tic;
i=0;
while (toc<inf)
i=i+1;
t(i)=toc;
v(i)=readDigitalPin(a,'D2');
plot(t,v,'b')
axis([0 inf 0 3])
pause(0.1)
if((v(i)-v(i+1)==1)) tic else d(i)=toc; end end
end

回答 (1 件)

Torsten
Torsten 2017 年 4 月 27 日
When you enter the if-statement, v(i+1) does not yet exist because the array v is only constructed up to element v(i).
Best wishes
Torsten.
  2 件のコメント
prajwal prabhu
prajwal prabhu 2017 年 4 月 27 日
how to rectify the above code???
Torsten
Torsten 2017 年 4 月 27 日
編集済み: Torsten 2017 年 4 月 27 日
Rectify the error that v(i+1) is undefined within the if-statement.
That's the only thing I can tell since I don't know what you are trying to do in your code.
Best wishes
Torsten.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by