1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Studying Programming too hard

  1. Oct 5, 2016 #1
    I'm not sure what to do, I keep on struggling with the matlab assigments and I'm a physics major. Any ideas on how to cope with this? Didn't really expect to be doing this much programming, and I do not like it.
     
  2. jcsd
  3. Oct 5, 2016 #2
    You don't need to cope with it, you need to get better at it. Whether you end up as a theorist or experimentalist, programming is a skill that is necessary. Unfortunately, you get better at programming by doing, so maybe try some practice exercises beyond what you do for class. If you don't understand the logic, maybe ask the TA or professor in your class to walk you through a program.
     
  4. Oct 5, 2016 #3

    berkeman

    User Avatar

    Staff: Mentor

    Is this the first time you've done any programming? Or have you done some programming in C or Perl or some other language before? Have you had any introductory programming classes yet, going over things like data structures, I/O, pointers, etc.?
     
  5. Oct 5, 2016 #4

    Krylov

    User Avatar
    Science Advisor
    Education Advisor

    Have you taken (or: are you taking) a course on linear algebra or another course featuring matrices? The primary data type in MATLAB is the matrix, so it helps when you are familiar with the very basics such as indexing, matrix and vector addition and multiplication, transposition, the dot product etc.

    Compared to e.g. C or Fortran, MATLAB is very forgiving and not difficult to learn if you are comfortable with the matrix structure. It may even become fun :smile:.
     
  6. Oct 5, 2016 #5
    Don't let 2 things come crashing on you. When I do octave/matlab I suffer from 2 things bellow.
    1-Programming syntax and stuff (loops and stuff)
    2-Extensive functions and data structure.

    How you can deal with it, forget about your academic requirement, learn a sweet and nice language, like python.
    everyday python at courasra dot org. Play with it .. enjoy it.

    Then go back to matlab. so you only have to deal with 2.
     
  7. Oct 6, 2016 #6

    chiro

    User Avatar
    Science Advisor

    Hey Mulz.

    You should probably tell us what the problem is so we can discuss it in more detail.

    There could be any number of reasons why you are finding something difficult and could range from a slight "misunderstanding" to a big conceptual difficulty.

    Let us know what it is so the forum can discuss it further.
     
  8. Oct 6, 2016 #7
    It's usually problem solving questions that tend to bother me. It is difficult to explain it but simply put I have a difficult time solving questions such as:

    1) Write a function min2(x,y) that takes two numbers x and y as in parameter and returns the lowest of them. If the numbers are equal the function will return any of them. Use the function definition to start with:

    function out = min2(x,y)
    %MIN2 Returns the smallest of two numbers
    __________________________
    Now this was only one example of a question I simply have trouble understanding. I did solve it with the help of my class mates but I would like to be able to solve matlab problems by myself, something I tend to struggle with. I usually understand the question, but not how the structure of the script should look like, like where am I supposed to use ex. a for loop and how do I explain a solution with the help of programming.

    What should I do? I understand mathematics easily but for some reason programming doesn't work for me, I'm below average in terms of intelligence so that should explain it?
     
  9. Oct 6, 2016 #8

    MarneMath

    User Avatar
    Education Advisor

    Whenever you encounter a problem that needs to be programmed, start with the naive solution. How would you do it by hand? Write it out step by step. If you are doing something over and over again then that may apply to a loop of some sort. There really is no way to get good at programming besides just programming. As you become familiar with the syntax and idioms within a language, the more adventurous you'll feel and the more complicated programs you can write.

    Anyway, here are some tips that help me.
    1. Don't immediately try to program an answer, take time to understand the problem and figure out how to do it by hand.
    2. Don't be afraid to make mistakes. Programs are easy to change, so if you're not sure how something works, try it out and see for yourself.
    3. In matlab, most things are done via vector type of operations, so be sure you are using the create arithmetic operator.
    4. Understand that most people struggle initially with programming, so you're not alone.
     
  10. Oct 7, 2016 #9

    chiro

    User Avatar
    Science Advisor

    In programming there are two main things - state of the machine and flow control.

    In mathematics, you typically don't define the state as explicitly which is why it can be confusing for mathematicians to understand code.

    In a procedural computer program you start with an initial state and you somehow need to take that [initial state] and get to a destination state.

    In a mathematical problem, you start with information and find a way to transform and combine it so that you get an answer that is consistent with everything you started with and provides the solution to your problem.

    In a programming problem, you do the same thing but you use a different language to do the same thing.

    Instead of going from a set of mathematical relations to a final set of relations that are consistent with what is given initially, you go from a memory state [which is a collection of "bits" arranged into data structures] to a final memory state [which again is a collection of bits arranged into data structures that are modified versions of the "original" or new ones derived from the "original" state].

    The difference between the two is the language and in procedural programming, you are dealing with a flow-chart that deals with things based on organizing bits instead of mathematical structures like real numbers or rational numbers.

    It might help you to think about stuff represented as a flow-chart and then to bridge the mathematics to computer code through the help of that flow-chart and how the information is represented inside a computer by a data variable or even by its binary representation in memory.

    For MATLAB, you won't have to worry about the binary representation [which is good for you] but if you can get the flow-chart intuition then over time it will get easier to convert that to actual computer code that you can both write and evaluate.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Programming too hard
  1. Course is too hard (Replies: 12)

Loading...