Getting an error saying "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters"

6 visualizaciones (últimos 30 días)
Here is my code that I have and I have checked to make sure there are correct number of parenthesis on both sides, but continues to give this error. Any help would be appreciated.
Code:
%%Root Mean Square envelope (moving average)- mean power of signal
envelope=zeros(L,4); %L= length(data)
%Window size in ms
window=50; %larger more of original signal but distortion and spikey, lower number could be flat
for i=1:4
envelope(:,i) = sqrt(movmean(((rec_signal(:,i).^2),window)));%Average according to moving window size; %sim to RMS
Unexpected ',' in parentheses. When creating a matrix, use square brackets [].
end

Respuesta aceptada

Image Analyst
Image Analyst el 11 de Jul. de 2025
Editada: Image Analyst el 11 de Jul. de 2025
You have too many parentheses. This works:
L = 21;
rec_signal = rand(L, 4);
%% Root Mean Square envelope (moving average) - mean power of signal
envelope = zeros(L,4); % L = length(data)
% Window size in ms
window = 50; % Larger more of original signal but distortion and spikey, lower number could be flat
for i = 1 : 4
envelope(:,i) = sqrt(movmean((rec_signal(:,i).^2),window)); % Average according to moving window size; %sim to RMS
end
  2 comentarios
Abhinit
Abhinit el 11 de Jul. de 2025
Yes that worked!! Thank you very much, sorry I missed the extra parenthesis on both sides. Appreciate your help.
Image Analyst
Image Analyst el 11 de Jul. de 2025
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
For full details on how to earn reputation points see: https://www.mathworks.com/matlabcentral/answers/help?s_tid=al_priv#reputation

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by