Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
BCM
User Panel

Posted: 11/24/2015 4:22:03 PM EDT
This script must be done in matlab and it states I need to create a script that has the following components... 1.must contain at lease three functions (at least two must accept parameter inputs), 2. input from the user, 3. output in graphs, 4. "if" or "switch" statements, 5. "for" or "while" statements.

I want to do something that pertains to small arms or ballistics. I made the following function that calculates recoil in ft/lbs, but I am lost on what to do and add from here. Does anyone else have any ideas? My script below seems useless since it would be almost impossible to calculate time to the target.

I'm honestly about to give up on calculating the recoil and try something else.  Any idea or suggestions from you Matlab experts out there?


function free_recoil
u=input('enter units for distance');
if u ==~ 'ft'  
   disp('please only use meters');
   end
end

function  velocity
d=input('Distance to target');
t=input('time to target');
V=d/t;
FPE(V)
end

function FPE(V)

clear

global M P W

M=input('weight of the projectile in grains:');

P=input('weight of powder charge in grains:');

W= 0:0.1:10;

Free_Recoil_Energy_in_FPE=((M.*V + 4700.*P)./7000).^(2)./(64.34809711)./(W)

if Free_Recoil_Energy_in_FPE <0, disp('error, not possible in the real world')

end

plot(W,Free_Recoil_Energy_in_FPE)

xlabel('Weight of Firearm in Pounds');

ylabel('Recoil in ft/lbs');

end
Link Posted: 11/26/2015 10:35:02 AM EDT
[#1]
Unfortunately, most of the really cool stuff in ballistic computation requires an understanding of ordinary differential equations, and how to numerically integrate them.

If you had that, you could very easily use MATLAB to put together a 2-DoF program that could simulate ballistic trajectories based on muzzle velocity, projectile mass and mach-dependent drag coefficient, air density, etc.
Link Posted: 11/26/2015 11:50:49 PM EDT
[#2]
Discussion ForumsJump to Quoted PostQuote History
Quoted:
Unfortunately, most of the really cool stuff in ballistic computation requires an understanding of ordinary differential equations, and how to numerically integrate them.

If you had that, you could very easily use MATLAB to put together a 2-DoF program that could simulate ballistic trajectories based on muzzle velocity, projectile mass and mach-dependent drag coefficient, air density, etc.
View Quote


Not true, at all.  Read up on Pejsa ballistics.  It gives a fairly simple formulation that is highly accurate once you establish the Chebychev constant for your load (but even this can be estimated and is subject to probabilistic variations.

I did a probabilistic point of impact (as opposed to point of aim).  It allowed for probabilistic variability in every conceivable input.  It took user inputs, had conditional branching (if's), gave outputs in graphical format (point of impact overlaid on the target), etc.

User can input ballistic properties of load - muzzle velocity and standard deviation of muzzle velocity.  

MATLAB functions can generate the probability distribution functions for the two main trajectory characteristics (drift and drop) based on random sampling of the PDF's for MV and SD.


I hope this helps, even if all it does is stimulate discussion and thinking.
Link Posted: 12/17/2015 5:52:40 PM EDT
[#3]
Quoted:
This script must be done in matlab and it states I need to create a script that has the following components... 1.must contain at lease three functions (at least two must accept parameter inputs), 2. input from the user, 3. output in graphs, 4. "if" or "switch" statements, 5. "for" or "while" statements.

I want to do something that pertains to small arms or ballistics. I made the following function that calculates recoil in ft/lbs, but I am lost on what to do and add from here. Does anyone else have any ideas? My script below seems useless since it would be almost impossible to calculate time to the target.

I'm honestly about to give up on calculating the recoil and try something else.  Any idea or suggestions from you Matlab experts out there?

View Quote


I'm not sure what exact help aspect you are looking for...

Just additional sub functions (as in what to also calculate), or how to get it all working together?


Based on your description of what is required, this is a pretty simple assignment. Along those lines, keep it simple.

Do a rudimentary ballistics calculator, not a full on one.  One function to calculate distance given initial height, velocity, and angle. One function to find maximum height. One function to find TOF.   Input variables can be height, gravity, angle, velocity. You switches and for/while loops can simple be over a range of the input values. or to compare values for different planets. Numbers on mars vs earth. Hell, add in mass and you can calculate energies.

Don't even dick around with anything more complicated than that, on a simple assignment like you've got described above. Meet all the requirements, get your 100%. Use the saved time for other classes.  
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.
Top Top