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

5 vues (au cours des 30 derniers jours)
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

Réponse acceptée

Image Analyst
Image Analyst le 11 Juil 2025
Modifié(e) : Image Analyst le 11 Juil 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 commentaires
Abhinit
Abhinit le 11 Juil 2025
Yes that worked!! Thank you very much, sorry I missed the extra parenthesis on both sides. Appreciate your help.
Image Analyst
Image Analyst le 11 Juil 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

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by