I'm writing a MATLAB program for solving the positive z and negative z traveling waves in a multiple region problem. The user chooses the number of layers to be N, and assume the characteristic parameters to be ei ; , µi , and oi in the ith region. The frequency f and the thicknesses di of the N layers is also part of the input data to the program.
I'm having trouble storing 4 variable inputs from the user e, u, o, and d for each individual array (region), store them into N (3 to 5, min. to max.) arrays, then calculate N times from the variable inputs.
c=3*10^8;
u0 = 4*pi*10^-7;
e0 = (36*pi)^-1*10^-9;
% Source parameters --------------------------
prompt = 'Enter number of regions (from 3 to 5)';
N = input(prompt)
prompt = 'Enter the frequency (in Hz) of the incident electric field';
f = input(prompt)
w = 2*pi*f;
% Region example parameters. Region starts from 1 to N -----------------
prompt = 'Enter region %d dielectric epsilon', i;
e = input(prompt)*e0 % region i epsilon dielectric
prompt = 'Enter region %d permeability mew', i;
u = input(prompt)*u0 % region i permeability mew
prompt = 'Enter region %d conductivity sigma', i;
o = input(prompt) % region i conductivity sigma
B = w*sqrt(u*e); % region i beta propagation constant
L = 2*pi/B; % region i lambda
prompt = 'Enter region %d thickness d (between 0 & 1/2)', i;
d = L*input(prompt) % region i thickness of dielectric material d
a = (w*sqrt(u*e)/sqrt(2))*sqrt(sqrt(1+(o/(w*e))^2)-1); % region i alpha
N = sqrt(u/(e-j*(o/(w) ) )) % region i intrinsic Impedance
Y = a+j*B; % region i gamma
% ---------------------------------------------------------------------
I am stuck figuring out to repeat the user input prompts for the ith region N times, then each variable input is stored into an array. I also believe I need a condition loop to repeat the input prompts up to N times starting from 1. Any help would be appreciated and if some clarification is needed, please ask.