From: JungMin on 9 Jul 2010 06:25 Dear all, I'm trying to make a simulink program from a m file i created. the inputs I want to control are gridd, r_width, r_height, w_width, w_height, which are all 1x1 scalar, constants. For this, i have created an m file called "parameters" and is ran before running the simulink simulation. The outputs refPr and Pr_ydB should be a 100x100 double matrix. This code runs well in the command window, but has problems when it is placed in the embedded MATLAB function block. When i play the simulation, it keeps saying that i have a problem during parsing embedded MATLAB fcn, and i also get an error for variable 'gridd', saying "The stride in this COLON expression does not appear to be constant. Only constant strides are supported" I hope someone knows solutions to my problems ... thank you in advance. ==================== The following is the eml code: ==================== function [refPr, Pr_ydB] = y_axis(gridd, r_width, U, r_height, w_width, w_height) %% Parameters c = 343; %% wave speed (m/sec) ro = 1.2; %% density of air (kg/m^3) lamda = 1 / 200 * c; %% wave length k = 2*pi/ lamda; %% wave number nx = 0; ny = 0; nz = 0; %% U = (1 / (2*pi*f) / ro * kz * exp(j*kx*[-0.49:gridd:0.49])); %% about y - axis ;* usual sound profile, planar, only x, z axis. y = 0; Pr_y=zeros(100,100); for x = (r_width-0.01) : (-1*0.02) : ((-1*r_width)+0.01) %x = (r_width-gridd/2) : (-1*gridd) : ((-1*r_width)+gridd/2) %* xz plane x = 0.99:(-1*gridd):-0.99 nx = nx + 1; for z = 0.01 : 0.02 : 1.99 %z = gridd/2 : gridd : (r_height-gridd/2) % z = 0.01:gridd:1.99 nz = nz + 1; temp = 0; nxw = 0; for xw = ((-1*w_width)+0.01) : 0.02 : w_width-0.01 %xw = -0.49:gridd:0.49 %* window grid center nxw = nxw +1; nyw = 0; for yw = ((-1*w_height)+0.01) : 0.02 : w_height-0.01 %yw = -0.49:gridd:0.49 nyw = nyw + 1; R = sqrt((x - xw).^2 + (y - yw).^2 + z.^2); temp = temp + U(nxw)*exp(j*k*R)/(R + 0.00000000001)*gridd^2; end end Pr_y(nx,nz) = (-1i*k*ro*c/2/pi*temp); %* y-axis sound pressure distribution? end nz = 0; end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% refPr = max(max(abs(Pr_y))); Pr_ydB = 10*log10(abs(Pr_y)./refPr);
|
Pages: 1 Prev: int quadgk disagree Next: question about radon transform |