Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So I have this matlab exercise for university..nothing too difficult but I'm new too the matlab thing and i got stuck..it is due tomorrow so I really need help! I will post the problem if anyone is willing to help I would appreciate it :)

Create a function that it will recieve an integer N (input) and it'll return two vectors P1 P2 (output) both with N size. P1's space will be [0,5] and it'll consists random numbers while P2's space will be[5,10] and consist of random numbers as well. Write every command that it will replace any number in P1 bigger tha 2.5 with 1 and any number in P2 smaller than 8 with 0.
Posted
Comments
Sergey Alexandrovich Kryukov 25-Oct-15 17:28pm    
Sorry, but this is not a question. Essentially, you are asking to do your University study assignment for you. The effect of doing this work for you would be purely negative. Do I even need to explain it to you?
—SA
[no name] 25-Oct-15 17:38pm    
I have a made some progress in writting the code but I'm stuck with an error that pops out that I can not understand..I don't know how this forum works but shouldi post the code that I wrote so far? Maybe you could help me with the mistake that I'm making!
Sergey Alexandrovich Kryukov 25-Oct-15 17:40pm    
Sorry, no code sample, no advice. We will gladly help you if you are confused with some particular aspect.
—SA
[no name] 25-Oct-15 17:42pm    
Ok so I'm confused with the integer part in matlab..Do you know if there is a way of defining a variable to be integer?
Sergey Alexandrovich Kryukov 25-Oct-15 20:15pm    
Why would the vector component be an integer?
—SA

Please see my comment to the question. Anyway, I'll advise you what to do.

Doing your assignment for you would be pointless. It would be unfair, first of all, to your fellow students who do this work by themselves. Importantly, it could disrupt your own education process, because your teachers may get wrong information on your actual progress and won't be able to correct their efforts accordingly.

So, here is the solution. You have two sound options: 1) work harder to solve the problem by yourself as well as possible; 2) come to your University adviser, or the head of your labs/seminars, or your lecturer on the topic and tell this person that you cannot cope with the assignment and explain why is that so, don't forget to explain what have you tried so far. This person will be able to correct her/his teaching to take your problems into account and advice your what to do. Perhaps some part of lecture or seminar was not clear enough, so you will need some additional explanation, more likely, you will need to read some documentation, textbook or other literature on the topic.

Note that the problem, as you wrote it, is not correctly formulated. "Write every command" is unclear. P1 is a vector, so it's not defined what "bigger than" may mean for a vector. It could be the length of the vector (I hope you know how to calculate it) or something else.

—SA
 
Share this answer
 
v3
Why not take a look at the various resources that are available online?

For example:
MATLAB Tutorial[^]
A Partial List of On-Line Matlab Tutorials[^]
INTRODUCTION TO MATLAB FOR ENGINEERING STUDENTS[^]

And then use Google for specific issues like generating random numbers.
 
Share this answer
 
Eruanneth asked:

Ok so I'm confused with the integer part in matlab. Do you know if there is a way of defining a variable to be integer?
No, this is not good talking. You are trying to do wrong things from the very beginning.

Essentially, the answer would be: http://www.mathworks.com/help/matlab/numeric-types.html[^].

But it won't really help you at this moment. You are starting with wrong steps. It's totally useless to do some programming without understanding the basics of the subject: general principles, technology and its goal, the language, and so on. You need to start from the very beginning, for example,
http://www.tutorialspoint.com/matlab[^],
https://en.wikibooks.org/wiki/MATLAB_Programming[^],
or something similar…

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900