Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Multiple inputs in MATLAB

  1. Nov 13, 2009 #1
    Hello. I have to do a beam project in MATLAB. Similar to this: (I just google imaged this)
    Just a simple beam with one or more applied loads.

    What I'm trying to do, is ask the user how many total loads are being applied to the beam. Once I have this answer, I want to have the user enter how much the load is, and what the position is. But, my problem is that once I have a number for how many loads there are, I don't know how to have that many questions asked. For example, if there are two loads, how do I get it to ask the user two times? Or if there are 4 loads, ask them for 4 separate values? I'm thinking it might be a for loop, or some type of loop depending on the number inputted.

    Last edited by a moderator: Apr 24, 2017
  2. jcsd
  3. Nov 14, 2009 #2


    Staff: Mentor

    A for loop sounds like the way to go. First, ask the user to enter the number N of loads, where N should be an integer 1 or larger.

    Then a for loop executes N times (for i=1:N) asking for for load(i) and position(i). After the for loop finishes you should have two arrays with N entries, load(1), load(2), ..., load(N), and position(1), ..., position(N). Then you're ready to do your load calculation.
  4. Nov 14, 2009 #3
    makes sense. ill give that a shot here soon and let you know how it works. thank you for the help :biggrin:

    edit: That definitely did work :smile: Now I can continue working with this. Thank you very much!!! :wink:
    Last edited: Nov 14, 2009
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook