Jump to content

  • Log In with Google      Sign In   
  • Create Account


MatLab: Div function?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 shadowstep00   Members   -  Reputation: 474

Like
0Likes
Like

Posted 29 October 2013 - 11:19 AM

First of all, I hope I posted in the right forum section.

 

Is there a Div function in MatLab? 

For example:  the div of 15/4 = 3?? 

 

I tried: 15 div 4

 

and i get an Error: Unexpected MATLAB expression.

 

I have been searching all over internet without finding anything...

I use the 2011 version.

 

Thanks in advance biggrin.png


Edited by shadowstep00, 29 October 2013 - 11:23 AM.

Failure is not an option...


Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 7868

Like
0Likes
Like

Posted 29 October 2013 - 11:36 AM

Divide and round the result. Depending on how you want to round negative numbers, you have the option to use floor or fix.



#3 shadowstep00   Members   -  Reputation: 474

Like
0Likes
Like

Posted 29 October 2013 - 11:43 AM

I know that it works by just making the  division then using floor.

 

But was wondering if there was a function. :P


Failure is not an option...


#4 Paradigm Shifter   Crossbones+   -  Reputation: 5208

Like
0Likes
Like

Posted 29 October 2013 - 11:46 AM

Never used MatLab. I have used google before though...

 

http://www.mathworks.co.uk/help/matlab/ref/idivide.html

 

It looks like

a ./ b

will work.

 

I googled "matlab integer division function"

 

EDIT: Maybe not, as I said I haven't used MatLab before... EDIT2: That looks like some kind of array operator, so go with idivide


Edited by Paradigm Shifter, 29 October 2013 - 11:51 AM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#5 shadowstep00   Members   -  Reputation: 474

Like
0Likes
Like

Posted 29 October 2013 - 11:51 AM

I just tried it does not work. :)

 

Anyways I created a div function myself for now. :P


Failure is not an option...


#6 Paradigm Shifter   Crossbones+   -  Reputation: 5208

Like
0Likes
Like

Posted 29 October 2013 - 11:58 AM

Yeah I realised it wasn't right and edited, looks like idivide is what you want. I can't do a search for ./ using the search box and it's not hyperlinked... not impressed with the MatLab documentation!


"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

#7 jjd   Crossbones+   -  Reputation: 2075

Like
0Likes
Like

Posted 01 November 2013 - 01:17 PM

First of all, I hope I posted in the right forum section.

 

Is there a Div function in MatLab? 

For example:  the div of 15/4 = 3?? 

 

I tried: 15 div 4

 

and i get an Error: Unexpected MATLAB expression.

 

I have been searching all over internet without finding anything...

I use the 2011 version.

 

Thanks in advance biggrin.png

 

There is this,

 

http://www.mathworks.com/help/matlab/ref/idivide.html

 

-Josh


--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet


#8 cadjunkie   Members   -  Reputation: 1274

Like
0Likes
Like

Posted 04 November 2013 - 08:27 AM

idivide is probably the function you want. FYI, you can also cast matrices to integers using int32() and other primitive types. 






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS