Getting an error saying "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters"
6 views (last 30 days)
Show older comments
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
end
0 Comments
Accepted Answer
Image Analyst
on 11 Jul 2025
Edited: Image Analyst
on 11 Jul 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 Comments
Image Analyst
on 11 Jul 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
More Answers (0)
See Also
Categories
Find more on Bartlett in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!