Expanding an equation in Matlab based on user input? Even possible?

1 view (last 30 days)
Greetings all,
I've been thinking about this all night and I don't even know if it's possible to do in Matlab, but for this question I am referring to page 8 of the following manual (sorry about the length of this question):
http://www.geonics.com/pdfs/technicalnotes/tn6.pdf
So, I'm coding up the equations in that manual and this is what I have so far:
Response_values_V= 0:0.01:3.5;
R_v=zeros(size(Response_values_V));
Response_values_H= 0:0.01:3.5;
R_h=zeros(size(Response_values_H));
for n=1:length(Response_values_V)
rValue_V = Response_values_V(n);
if rValue_V < 3.6
R_v(n)=1/sqrt(4*rValue_V.^2+1);
else
R_v(n)=0;
end
end
for n=1:length(Response_values_H)
rValue_H = Response_values_H(n);
if rValue_H < 3.6
R_h(n)=sqrt(4*rValue_H.^2+1)-2*rValue_H;
else
R_h(n)=0;
end
end
z1 = input('Enter z1 value = ');
z2 = input('Enter z2 value = ');
sig1 = input('Enter conductivity of the first layer = ');
sig2 = input('Enter conductivity of the second layer = ');
sig3 = input('Enter conductivity of the third layer = ');
z1scaled = z1*100;
z2scaled = z2*100;
sig_a_v = sig1*(1-R_v(z1scaled))+sig2*(R_v(z1scaled)-R_v(z2scaled))+sig3*R_v(z2scaled);
sig_a_h = sig1*(1-R_h(z1scaled))+sig2*(R_h(z1scaled)-R_h(z2scaled))+sig3*R_h(z2scaled);
As you can see I coded up Figure 7 in this pdf and extended the limits to 3.5 (V is for vertical polarization and H is for Horizontal, and the equation for Figure 7 is found on the last page of that pdf), and matched codding up the equation at the bottom on page 8. Granted this is for a 3 layer system with 3 conductivities, and I have user input to define the conductivities as well as the thickness "z" of the layered model as shown in the pdf. I also scaled "z" since I plot (code withheld for brevity) by .01 increments, not 0.1.
Anyway, while this code works only for this example here, what would I need to do in Matlab to change
sig_a_v = sig1*(1-R_v(z1scaled))+sig2*(R_v(z1scaled)-R_v(z2scaled))+sig3*R_v(z2scaled);
on the fly?
Say I have 4 layers and for conductivities, it would have to look something like
sig_a_v = sig1*(1-R_v(z1scaled))+sig2*(R_v(z1scaled)-R_v(z2scaled))+sig3*(R_v(z2scaled)-R_v(z3scaled))+sig4*R_v(z3scaled);
See how I lengthened the equation based on an additional layer? I'm trying to do this for n layers based on user input.
Is this even possible?
Thanks! -J

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!