Help With Starting Code
2 views (last 30 days)
So I'm attempting to write a code that does the following:
Use a function (volume of a sphere cap) and user defined inputs: r (radius), max r, amount to increment by, and the number of heights (of the liquid). It needs to create a table of h values vs volume values.
I know I will need to use two loops: one for r and one for h, and I also have the function created. I'm having some trouble getting it all started though, since I am newer to MATLAB. Any and all help is appreciated. Thank you in advance!
Here is my function:
function out = VOLUME_SPHERE_CAP(h,r)
%VOLUME_SPHERE_CAP Summary of this function goes here
% h is liquid level
% r is radius of sphere
Rishabh Rathore on 4 Jun 2018
What i get from your question, you want a code that gives you the pairs of h and volume for all r and h.The code below creates a structure result, which has elements h and vol, using your function 'VOLUME_SPHERE_CAP'.
% get input from user for h() vector of values of h, increment, r_min, r_max
result.h=[result.h h] %best practice would be to pre-locate the structure 'result'