Function with duplicate name "aAcou1" cannot be defined.

% this function calculates and plots the sound pressure of a single source
c= 343;
function [spl] = aAcou1(f,P,t)
if f == 40
A1 = 10 ;
A2 = 10;
w = 2*pi*f;
k = w/c;
end
x = [1:h:12];
y = [1:h:15];
[yy,xx]= meshgrid(y,x);
H1 = sqrt((xx-0).^2+(yy-9).^2);
H2 = sqrt((xx-9).^2+(yy-16).^2);
Lx = length(x);
Ly = length(y);
phase = zeros(Lx,Ly);
phase2 = zeros(Lx,LY);
Meanpressure = zeros(Lx,Ly);
spl = zeros(Lx,Ly);
for a = 1:Lx
for b = 1:Ly
phase(a,b)= ((A1+P)./H1(a,b))*exp(1j*((w*t)-(k*H1(a,b))));
phase2(a,b)= ((A2+P)./H2(a,b))*exp(1j*((w*t)-(k*H2(a,b))));
end
end
phase3= phasor+phase2;
for a = 1:Lx
for b = 1:Ly
Meanpressure(a,b) = sqrt(0.5*phase3(a,b)*conj(phase3(a,b)));
spl(a,b)= 20*log10(Meanpressure(a,b)/(20*10^(-6)));
end
end
figure
surf(X,Y,spl)
end
I am confused why I get the error Function with duplicate name "aAcou1" cannot be defined. I have save it as the same name and only have one file of aAcou1 ,confused lol.

Réponses (1)

madhan ravi
madhan ravi le 27 Avr 2019
Modifié(e) : madhan ravi le 27 Avr 2019
Save the code in a separate file named as aAcou1.m , define c inside the function. Why so obssessed with that name ?? Why if you change the name to aAcoU the earth won't spin or what?
which aAcou1 -all % to see if any other file exists with the same name

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by