I've been working on this code for some hours and it seems I'm doing something wrong which I just can't figure out. I have a function which I integrate and then plot it's values. But the graph I get looks strange. I expected some form of an exponential function but the one I get is far away from my anticipations, and when I try changing some of my constants, it does still behave in a strange manner. This is how the code looks like:
y = 0:0.5:D; p = 65.5; k = 1; D =10:0.5:100; %Create a vector for D M =zeros(1,181); %an array for j = k:181 %For loop for all water values M(k) = integral(@(y) Func5(p,D,k,y),0,D(k)); k+1; end plot(D,M) title('Hydrostatic pressure in bars'); xlabel('water level in fot'); ylabel('pressure i bars');
And this is the code for my function:
function FD = Func5(p,D,k,y) w = 40-20*exp(-(0.01*y))*2; %Width of the dam FD = p.*(D(k)-y).*w; %Claculate the pressure end
Thanks in advance for any help.