I am receiving this error : Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Surabhi A S
el 23 de Ag. de 2022
Comentada: Dyuman Joshi
el 25 de Ag. de 2022
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 comentarios
Dyuman Joshi
el 23 de Ag. de 2022
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.
Respuesta aceptada
Dyuman Joshi
el 23 de Ag. de 2022
Editada: Dyuman Joshi
el 23 de Ag. de 2022
a = readmatrix('a.xlsx');
b = readmatrix('b.xlsx');
c = readmatrix('c.xlsx');
%I have not suppressed the outcome so you can verify the values of a
%as the first value will be read as NaN (not a number)
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
%since there are 10 elements in the arrays, the index should go from 1-10
n = 1;
while (n < 11)
if (0 < Up(n) | Right(n) > 30)
disp('Fall is detected')
break %breaking the loop
else
disp('No fall')
end
n = n+1;
end
8 comentarios
Dyuman Joshi
el 25 de Ag. de 2022
That should not be happening, if x>30 then it is automatically x>0
Is your data still the same?
Más respuestas (1)
Abderrahim. B
el 23 de Ag. de 2022
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 comentarios
Dyuman Joshi
el 23 de Ag. de 2022
Editada: Dyuman Joshi
el 23 de Ag. de 2022
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.
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!