I am receiving this error : Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported.
이전 댓글 표시
When i try to run this code I'm receiving this error:
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more
subscripts) is not supported. Use a row subscript and a variable subscript.
a(1:11) %Imported data from excel
b(1:11) %Imported data from excel
c(1:11) %Imported data from excel
Resultant = sqrt(a*a + b*b + c*c);
Up = 180*atan2(a, sqrt(b*b + c*c))/pi;
Right = 180*atan2(b, sqrt(a*a + c*c))/pi;
while (0 < n < 11)
if (0 < Up || Right > 30)
disp('Fall is detected')
else
disp('No fall')
end
end
댓글 수: 2
Dyuman Joshi
2022년 8월 23일
The code you have showed us is incomplete
- There are no a, b anc c values defined/assigned.
- You have not initiated a loop counter nor is the loop counter updating according to conditions.
Surabhi A S
2022년 8월 23일
채택된 답변
추가 답변 (1개)
Abderrahim. B
2022년 8월 23일
Hi!
We don't import data from excel that way.
In your case better to use readmatrix:
A = readmatrix(yourFile.xlsx) ;
If you want to have the data as table use readtable:
tbl = readtable(yourFile.xlsx) ;
Hope this helps
댓글 수: 5
Surabhi A S
2022년 8월 23일
Here is a demo based on your data:
a = readmatrix('a.xlsx') ;
b = readmatrix('b.xlsx') ;
c = readmatrix('c.xlsx') ;
a = a(2:11) ; %Imported data from excel
b = b(2:11) ; %Imported data from excel
c = c(2:11) ; %Imported data from excel
Resultant = sqrt(a.*a + b.*b + c.*c);
Up = 180*atan2(a, sqrt(b.*b + c.*c))/pi;
Right = 180*atan2(b, sqrt(a.*a + c.*c))/pi;
n = 0;
while ( n < 11)
if (0 < Up | Right > 30)
disp('Fall is detected')
else
disp('No fall')
end
n = n+1;
end
Abderrahim. B
2022년 8월 23일
편집: Abderrahim. B
2022년 8월 23일
Note that the function readmatrix was first Introduced in R2019a. If you are using an older release MATLAB will throw an error. Consider to use dlmread instead.
Surabhi A S
2022년 8월 23일
Dyuman Joshi
2022년 8월 23일
편집: Dyuman Joshi
2022년 8월 23일
Since you are looking to compare individual values, make this change
%replace
if (0 < Up | Right > 30)
%with
if (0 < Up(n) | Right(n) > 30)
and adjust the loop counter accordingly.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!