I am currently trying to run a script to plot two graphs but I keep having this error "Undefined function or method 'greens' for input arguments of type 'char'."

2 views (last 30 days)
%%% PARAMETERS %%%
lx = 5.0; % x-dimension of the room (meters)
ly = 6.0; % y-dimension of the room (meters)
lz = 4.0; % z-dimension of the room (meters)
V = lx*ly*lz; % Volume of the room
c = 344; % speed of sound in air
p0 = 1.204; % density of sound in air
pref = 20 *10^(-6);
prms = [20*10^-6:100:100] ;
%%% GF as function of Frequency PARAMETERS %%% fd = [0:10:100]; % frequency range
x1 = 0.1; y1 = 0.1; z1 = 0.1; x0 = 0.0; y0 = 0.0; z0 = 0.0; An =sqrt(2);
f01 = 50; % 1 fixed frequency <<
%%Calculated Parameters%%
w= 2 *pi *f01; %%angular frequency
lambda = c/f01; %%wavelength
k = (2*pi)/lambda; %%Wavenumber
%%% N- Values of x,y,z given k%%%%
nx= (k*lx)/pi;
ny= (k*ly)/pi;
nz= (k*lz)/pi;
%%%% P(x,y,z) for phi(r) Calculation -> close to error sensor %%%
px1 = (x1*pi*nx)/(lx);
py1 = (y1*pi*ny)/ (ly);
pz1 = (z1*pi*nz)/(lz);
phi_r1 = An * cos(px1) * cos(py1) * cos(pz1);
%%%% P(x,y,z) for phi(r0) Calculation -> sensor %%%
px0 = (x0*pi*nx)/(lx); py0 = (y0*pi*ny)/ (ly); pz0 = (z0*pi*nz)/(lz);
phi_r0 = An * cos(px0) * cos(py0) * cos(pz0);
%%eigen frequency%%% c1 = c/2; k1 = (nx/lx)^2; k2 = (ny/ly)^2; k3 = (nz/lz)^2;
k123 = k1 +k2+k3;
fn = c1*sqrt(k123); wn = 2*pi*fn;
%%%%Greens Function %%%%%
n = -1i * w * p0 *c^2 *phi_r0 * phi_r1; %% Numerator
d = (w^2 - wn^2)*lambda; %% Denominator
g = n/d;
%%Sound power Level&&
SPL = 20*log10(prms/pref);
%%Plot Sound Power Level against greens function &&
figure(1);
plot(fd,SPL');
title('Greens function in a room');
xlabel('Frequency (Hz)');
ylabel('SPL (dB)');
hold on;
figure (2); plot(g, SPL') title('Greens Function within a Room'); xlabel('Greens Function'); ylabel('SPL (dB)'); hold on;

Accepted Answer

Walter Roberson
Walter Roberson on 13 May 2014
What did you name the script? The name must not have any spaces in it.

More Answers (1)

Clarissa
Clarissa on 13 May 2014
Thanks so much!
Fixed it :)

Categories

Find more on Just for fun 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!