dot indexing not supported for this type of variable” error

8 visualizzazioni (ultimi 30 giorni)
% Perform prediction
pred =model.predictFcn(audioTable);
For this code
There is a "Dot indexing is not supported for variables of this type error"
function audioTable = extractFeatures(~, filePath)
% Ensure filePath is a valid string (for debugging purposes)
if ~ischar(filePath) && ~isstring(filePath)
error('Invalid file path');
end
% Reading audio file
[y, ~] = audioread(filePath);
% Processes the signal to suitable format
y1=abs(spectrogram(y,kaiser(2048,128),120,16,1E3,'yaxis'));
y1=y1(:);
audioTable=[];
t=0;
if length(y1)>=3087
y1=y1(1:3087);
else
t=1;
end
if t==0
audioTable=[audioTable y1];
end
end
and This is the code that I wrote. How can I fix this error?
  2 Commenti
dpb
dpb il 5 Dic 2024
What does
whos model
return?
And what generated it? It is undefined in the above code.
Image Analyst
Image Analyst il 5 Dic 2024
Modificato: Image Analyst il 5 Dic 2024
Which version of predict() are you using? There are lots of them. Are you sure it's not supposed to be like this:
pred = predictFcn(model, audioTable);
Check the arguments that are expected for the specific version of predict you're using. It's overloaded so the version of predict that gets used depends on what arguments you feed it. What does this show in the command window:
whos model
which -all model
which -all predict

Accedi per commentare.

Risposte (2)

Subhajyoti
Subhajyoti il 5 Dic 2024
Hi @Ceren,
The function 'audioTable = extractFeatures(~, filePath)' is returning a vector (nx1 double) or a null element '[]'.
In MATLAB, dot indexing is typically used with structures, tables, or objects, where you access fields or properties using a "." (dot). However, when you try to use dot indexing on a vector, MATLAB throws the error because vectors do not have fields or properties that can be accessed with dot notation. You can use parentheses '( )' for indexing and manipulation of elements of a double array.
Thus, for resolving the error, you need to ensure that appropriate operations are performed in the 'predictFcn' method to get results from the input 'audioTable'.
Refer to the following MathWorks Documentation to know more about 'Array Indexing' in MATLAB:

Walter Roberson
Walter Roberson il 5 Dic 2024
When you use predictFcn, the input data needs to be in the same format that you trained on.
If you trained on a table() object, then you need to pass predictFcn() a table() object. But you are passing numeric data instead.

Categorie

Scopri di più su AI for Signals in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by