f



Matlab arithmetic bit shifting right

Does anybody know how to perform an arithmetic bit shift right in
Matlab? I tried using bitshift, but it cuts off the decimal points
(i.e. bitshift(6.625,-2) = 1, but it should be 1.75). I have also
tried to get the binary number using the bitget function, but it too
cuts off the decimal points and returns (1100 or 6). Thanks in
advance.
0
5/6/2004 3:56:26 PM
comp.soft-sys.matlab 211264 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
450 Views

Similar Articles

[PageSpeed] 41

"John Ryan" <jballgame20@aol.com> writes:

> Does anybody know how to perform an arithmetic bit shift right in
> Matlab? I tried using bitshift, but it cuts off the decimal points
> (i.e. bitshift(6.625,-2) = 1, but it should be 1.75). I have also
> tried to get the binary number using the bitget function, but it too
> cuts off the decimal points and returns (1100 or 6). Thanks in
> advance.

The bit*** functions assume "flints", or integers represented as
floating point values.

What binary value do you think you should get for 6.625?

-- 
Peter Boettcher <boettcher@ll.mit.edu>
MIT Lincoln Laboratory
MATLAB FAQ: http://www.mit.edu/~pwb/cssm/
0
boettcher (2304)
5/6/2004 8:47:50 PM
Also, starting in version MATLAB 6.5 (Release 13) non-flint inputs to
bitshift actually error:

>> bitshift(6.625,-2)
??? Error using ==> bitshift
Inputs must be integers.

whereas before it would have silently truncated 6.625 to 6.

Penny Anderson
The MathWorks, Inc.

"Peter Boettcher" <boettcher@ll.mit.edu> wrote in message
news:m3zn8lp9jd.fsf@coyote.llan.ll.mit.edu...
> "John Ryan" <jballgame20@aol.com> writes:
>
> > Does anybody know how to perform an arithmetic bit shift right in
> > Matlab? I tried using bitshift, but it cuts off the decimal points
> > (i.e. bitshift(6.625,-2) = 1, but it should be 1.75). I have also
> > tried to get the binary number using the bitget function, but it too
> > cuts off the decimal points and returns (1100 or 6). Thanks in
> > advance.
>
> The bit*** functions assume "flints", or integers represented as
> floating point values.
>
> What binary value do you think you should get for 6.625?
>
> -- 
> Peter Boettcher <boettcher@ll.mit.edu>
> MIT Lincoln Laboratory
> MATLAB FAQ: http://www.mit.edu/~pwb/cssm/


0
5/7/2004 1:06:25 PM
Reply:

Similar Artilces:

can Matlab support 32-bit matlab version scripts on 64-bit version of matlab
can Matlab support 32-bit matlab version scripts on 64-bit version of matlab in windows platform?.if yes , how is the performance better ? please do answer this question thank u "Gangamma " <gangvsng@gmail.com> wrote in message <hvmr7h$sn0$1@fred.mathworks.com>... > can Matlab support 32-bit matlab version scripts on 64-bit version of matlab in windows platform?.if yes , how is the performance better ? Yes, Matlab program written in 32/64 bits are compatible accepted MEX file. 64-bit version can handle larger array but does *NOT* improve speed. Br...

can Matlab support 32-bit matlab version scripts on 64-bit version of matlab #2
can Matlab support 32-bit matlab version scripts on 64-bit version of matlab in windows platform?.if yes , how is the performance better ? please do answer this question thank u ...

64-bit Matlab scripts on 32-bit Matlab?
Hello, I wish to use script which perform some simple calculations on NetCDF variables and store result values as a matrix. Author claims that script needs 64-bit MATLAB version installed on Linux machine. Unfortunately, although I have 64-bit machine, under Linux I have access to 32-bit MATLAB only. Following warning is returned: Error using class The CLASS function must be called from a class constructor. Could you tell me: - what (in terms of syntax, available functions, methods, objects) are the differences between 64-bit and 32-bit MATLAB? - is it possible to workaround such problems in 32-bit MATLAB? - will it be possible to run mentioned script in 64-bit MATLAB under Windows? "Mateusz" wrote in message <leddln$pfc$1@newscl01ah.mathworks.com>... > Hello, > > I wish to use script which perform some simple calculations on NetCDF variables and store result values as a matrix. Author claims that script needs 64-bit MATLAB version installed on Linux machine. > > Unfortunately, although I have 64-bit machine, under Linux I have access to 32-bit MATLAB only. > Following warning is returned: > > Error using class > The CLASS function must be called from a class constructor. > > Could you tell me: > - what (in terms of syntax, available functions, methods, objects) are the differences between 64-bit and 32-bit MATLAB? > - is it possible to workaround such problems in 32-bit MATLAB? > -...

How to do >>(right shift) and <<(left shift) in Matlab?
Hi all, How >>(right shift) and <<(left shift) 2'complement number (both positive and negative integer). Is x>>2 equal to floor(x/4)? And is x<<2 equal to x*4? Best regards, Davy Soho wrote: > Hi all, > > How >>(right shift) and <<(left shift) 2'complement number > (both positive and negative integer). > > Is x>>2 equal to floor(x/4)? > > And is x<<2 equal to x*4? > > Best regards, > Davy > Does bitshift: http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bitshift.html do what you wa...

Run Matlab ... from Matlab
Hello, Is there any limitation to run Matlab from Matlab, as a system command, on Linux platforms ? I tried to start Matlab, both using the ! syntax (!matlab&) or the system command (system('matlab&')), the Matlab splash screen appears, but the new Matlab session closes rapidly . When I do the same with a script of mine (system('matlab -r "myscript"&')), my script is being executed, but Matlab finally crashes . If I remove the &, it works well, but the first Matlab session is blocked till I close the second one . I run Matlab on a Linux 64bits pla...

Signed right shift in Matlab?
Hi all, I want to find a emulation method in Matlab. For it only provide unsigned shift(function bitshift). But I need a signed version. %% out=in>>n; %% in and out both in signed integer Function[out]=right_shift(in,n) floor(in/(2^n)); When right shift, copy signed bit to right. Is the function right? Best regards, Davy ...

MATLAB talking to MATLAB?
For my project, I need to have a client program (MATLAB executable) talking to a server program (also MATLAB executable) to query data. Is there any easy way to accomplish that? I appreciate any help that I can get on that. Thanks. Cheers, Hoi Oops, I forgot to mention. There are multiple clients querying the server, so I guess serial objects + remote serial port wouldn't work. "Hoi Wong" <wonghoi.ee@gmail.com_> wrote in message news:f3ald6$gg4$1@news.Stanford.EDU... > For my project, I need to have a client program (MATLAB executable) > talking to a ser...

Spawning matlab from within matlab
Hello all, I would like to spawn multiple matlab processes from an '.m' script. Meaning, run an m-file from a 'parent' Matlab that launches, say, 8 more 'children' matlab processes. I'd like to do it in such a way that the same m-file in the 'parent' is able to close down, or kill, all the 'children' processes. Any suggestions? Joe ...

Matlab plots outside Matlab
I'm making an end-user application where I would like to use Matlab functionality both for calculation and plotting. Matlabs GUI builder guide does not satisfy my needs (no support for f.ex. internal frames and other nescessities), so I'm planning to compile my Matlab code and use other API (Java, QT or something) for GUI. My problem is then, that I loose access to the neat plotting commands availible under matlab GUI... Is there a way of integrating Matlabs plot functionality into another GUI system? - has it been done? - I appreciate any response! - P�l Berge ...

DLL creating by Matlab for Matlab
I would like to know if it is possible to convert several M-files into one DLL with Matlab (by using mcc or mex or other functions) and use this DLL with Matlab. How can I do that? I could create DLL with mcc -l xxx.m but I can't use this DLL with Matlab (error: "??? The function, script or class xxx cannot be indexed using {} or . indexing.") I have a project on Matlab with just M-files and I want to give this project to someone who want to use it on Matlab too, but I don't want to give him the source M algorithms. Moreover, I don't want to have an executable....

Calling Matlab in C in Matlab
Hi everybody! My problem can be described as follows. I have a tool in Matlab that requires calling an optimisation algorithm in C. This algorithm consists of several C-files, one of which contains the function to be minimised (CFUNCTION), and another is the main algorithm file (CMAIN). Now what I want to do is to call Matlab from CFUNCTION or CMAIN and specify my custom function (MFUNCTION) to be minimised. So, I'm calling Matlab from C from Matlab. I'm a newbie in C and MEX files. Should I rewrite CMAIN as a MEX file and include CFUNCTION in this and then use mxCallMATLAB? Or can...

arithmetics in matlab
Hi, when Matlab performs 1/(4.1-4), the result in double precision is 10.000000000000036 I am not quite sure why there is a 36 at the very end? Thank you "pluton schmidt" wrote in message <jed8mg$m4q$1@newscl01ah.mathworks.com>... > Hi, > > when Matlab performs 1/(4.1-4), the result in double precision is 10.000000000000036 > I am not quite sure why there is a 36 at the very end? Thank you Welcome to the wonderfully wacky world of floating point arithmetic. Computers use BINARY arithmetic, not decimal arithmetic. This means that you cannot represent number...

Calling Compiled MATLAB from MATLAB
Hello everyone, How do I compile MATLAB M files into a form that can then be called from within the MATLAB interpreter? A roundabout way would seem to be to (somehow) Turn the matlab code into C (I think mcc does this), then compile this C code into MEX format and call that. Is there an easier way? I have the MATLAB compiler, so I just need to know what to do with it to get this to work. Thanks in advance, Sina sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that. Is there an > easier > way? I have the MATLAB compiler, so I just need to know what to do > with > it to get this to work. > > Thanks in advance, > > Sina > > HELP MEX > HELP MEX Or, better, HELP MCC help pcode pseudo code is useful to obfuscate code - protect algorithms, yet still run at full speed and be distributable to other matlab users sina.tootoonian wrote: > > > Hello everyone, > > How do I compile MATLAB M files into a form that can then be called > from within the MATLAB interpreter? A roundabout way would seem to > be > to (somehow) Turn the matlab code into C (I think mcc does this), > then > compile this C code into MEX format and call that...

What is the best way to import Excel files, with stock data, into Matlab? I’m using Matlab R2010b (64-bit)
What is the best way to import Excel files, with stock data, into Matlab? I’m using Matlab R2010b (64-bit) I’m trying to import historical prices of stock data. Matlab keeps cutting off the header of each column; it gives me only values. I am thinking that this is a data-type-mixing-issue, or whatever it’s called. I have ‘Dates’ in ColumnA, and ‘MSFT’, ‘PWER’, ‘KO’, and ‘SBUX’, in ColumnB-ColumnE. Basically, if I put the Excel file in my Matlab folder and double-click the file, I see the values in a matrix (no dates and no headers), I hit ‘Next’. Then, I see only one option; one radio button is enabled – ‘Create variable matching preview’. The other two options, ‘Create vectors from each column using column names’ and ‘Create vectors from each row using row names’ – both are greyed out. I’ve seen videos, on YouTube and on the Matlab site, where people import excel data and these options are NOT greyed out. No matter what I do, there options are ALWAYS greyed out. The problem is, when I click ‘Finish’ in my ‘Workspace’ I have a variable named ‘data’ all values in a 575x4 matrix, but I have NO DATES and I have NO HEADERS on the columns. All of this seems to go into another variable, called ‘textdata’; all dates and headers ate in textdata. This is VERY inconvenient. I’m trying to analyze some stock data and I have no headers, so I have no idea which stock is which (I can figure it out, but I think Matlab should do this for me). Also, I have no dates corresponding to ...

from Delphi to matlab and matlab to delphi
How to send vars from Delphi to Matlab ? and viceverse, from matlab to delphi ? thanks, it is dificult, and not found answers in the internet. jairo serrano wrote: > > > How to send vars from Delphi to Matlab ? and viceverse, from matlab > to delphi ? thanks, it is dificult, and not found answers in the > internet. When I want to use Matlab variables in another program, I write them to file. You can use comma separated files (csv). Try: > help csvwrite > help dlmwrite Works fine for me. Hope this helps, Niels jairo serrano wrote: > How to send vars from Delphi to Matlab ? and viceverse, from matlab > to delphi ? thanks, it is dificult, and not found answers in the > internet. The simplest is with OLE. Have a look here: - Francis Burton, "Callin Matlab from Delphi" #, 19 Nov 2003 4:27 pm </WebX?50@@.eecb61d> Two sample projects are given here: - <http://www.djpate.freeserve.co.uk/Matlab.htm> From Matlab to Delphi you would have to write a mex files, thats more difficult. Regards, Peter hi i did the connection between delphi4.0 and matlab6.5 and I could cacth the value from Delphi to Matlab but can't to cacth the value from Matlab to Delphi, Do you have an idea??? I think that this project it is look like with yours , Did you make this project? Thanks in Advance, Thiago Holanda jairo serrano wrote: > > > How to send vars from Delphi to Matlab ? and viceverse, from matlab > to delphi ? thanks, it...

Matlab arithmetics
Dear All I initialize my data-variable like this: myDataMatrix = -1. To chech wether I put some Data into the matrix, I do the following: if (myDataMatrix ~= -1) whatever I want to do with the data end; Unfortunately, if I assign a matrix to myDataMatrix, I do not get the block I want to be executed. Can anybody please help? Pascal Pascal Steiss wrote: <SNIP .. If-problem with matrices. The conditional expression evaluates to a single true or false. For matrices M, the expression M~=-1 is true when all values in M are unequal to -1. You can use: if ~isequal(M,-1), ... end ...

parallel matlab
Hi all, I'm going to work on a project involving a parallel version of MATLAB - I'm aware of various efforts like MATLAB-*P and so on Right now I need to read up on some material regarding MATLAB internals eg: How are the ATLAS(or is it BLAS) routines called in MATLAB? How does MATLAB's C code store information in memory, cache'ing etc? How is one to get at those? Do you know of any suitable reference(s)/resource(s)? Thank you very much, Aravind ...

matlab in JAVA or java in MATLAB?
Hi guys I am now experencing a great difficulty in the interation between java and matlab. I have an objective function written in JAVA with has method return an numerical number, i call it 'profit'. The nature of this obtive function (ObjFun.java) is that it takes an parameter input, say C, with different C value, the returned profit value is different. Eventually I want to find the optimized C value which produce the maximun profit (C will be under constrains). Initially I want to use linprog or fminsearch in matlab. So I tried the command in matlab that excutes my ObjFun.java. But it failed because my ObjFun.java will call an external .exe file. and the file path contains spaces which is fine by Java but not matlab. I stuck here, I myself is a Java programmer not good at matlab, I can't find any thing on google about the solution to my problem. So here I propose another idea: call matlab function in JAVA. I need some advise on this. Thank you very much for a reply!!! Lemon can anyone give advice?? "Lemon F" <f.lemon.jin@hotmail.com> wrote in message <i3bag7$i96$1@fred.mathworks.com>... > can anyone give advice?? If you would not have double-posted you would have seen that you already received advice (on the other post): http://www.mathworks.com/matlabcentral/newsreader/view_thread/288403 ...

Why Matlab 7.3 does not support 64-bit integer arithmetic
Hi, I tried to perform some elementary arithmetic operations on 64-bit integer values in the latest release of Matlab 7.3/R2006b. I found that these very simple operations just does not work: >> I1 = int64(java.lang.System.currentTimeMillis()) I1 = 1161290545975 >> I2 = int64(java.lang.System.currentTimeMillis()) I2 = 1161290555316 >> I = I2 - I1; ??? Undefined function or method 'minus' for input arguments of type 'int64'. >> I = I1 + I2 ??? Undefined function or method 'plus' for input arguments of type 'int64'....

Matlab engine with matlab R2010b
Hello All, I'm working with an aplication that use the matlab engine. I made the C++ program and it is working well in my pc with matlab 2007b, but the same very basic program shows an error when I tried to compile it in a pc with matlab R2010b. The error is about the icuuc32.dll. ¿Why is asking this DLL? How can I solve this?. Thanks¡ ...

matlab to matlab remote execution
Hi I have two win PCs running matlab 7. One is slow and other is a high spec fast PC. They are connected to LAN. The directory on fast PC where all matlab work takes place has been mounted as a drive on slow PC. Hence this directory on fast PC can be accessed from slow PC's matlab session. I want to let the user on slow PC run some computationally intense M scripts in his matlab session but execute them on fast PC. I tried usual unix like method. First installed telnet server on fast PC. Then used telnet client on slow PC to log on fast PC. If I attempt to start matlab in slow PC telnet ...

C++ Mex file crashes matlab on 64bit linux, but not 32 bit windows, but program runs fine outside Matlab
Hello, I have written a mex gateway function to a C++ class. If I compile this mex function on 32Bit windows using R2008a I have no problems. If I compile and run on Matlab R2011a running 64bit Scientific Linux (a version of Red Hat Enterprize Linux) matlab exits with a segfault when the mexfunction is called, although it appears to run about halfway through the program. The C++ class can be compiled and run (with a main function) outside of Matlab on both platforms with no errors. I am using Microsoft Visual C++ Express Edition on the windows machine, and gcc 4.4.5 on the Linux machine. ...

Can anyone help me that How can i make the MATLAB-simulink model faster?? I am using, MATLAB 7.9.0(R2009b(64-bit).
When i am running my simulation model in MAT-Lab,it takes more time.Can anyone help me that How can i make it faster?? Initially,i kept it on "Normal Mode"...Simulation is very Slow .But,when I kept on "Accelerator Mode"....it is not working means some Error is coming. The Error is:-... "Unable to locate a Visual C/C++, Watcom, Borland, Intel, or LCC compiler. Please define one of the following environment variables: Real-Time Workshop builds with Microsoft Visual C on 64 bit windows require that the compiler be installed. At least one of these environment variab...

Matlab
Hello , I'm a new user in Matlab. So should you advise matlab notes , documentation please ? <azatserver113@gmail.com> wrote in message news:7b4e75e2-40c6-43bb-acc6-2553123ba649@googlegroups.com... > Hello , > > I'm a new user in Matlab. So should you advise matlab notes , > documentation please ? > At the MATLAB command prompt type this command: doc This will show the documentation included as part of your installation. I recommend reading through the Getting Started section of the MATLAB documentation first, and executing the examp...

Web resources about - Matlab arithmetic bit shifting right - comp.soft-sys.matlab

Arithmetic - Wikipedia, the free encyclopedia
... of numbers , especially the properties of the traditional operations between them— addition , subtraction , multiplication and division . Arithmetic ...

Arithmetic - Wikipedia, the free encyclopedia
... numbers , especially the properties of the traditional operations between them — addition , subtraction , multiplication and division . Arithmetic ...

Mental Arithmetic - train your brain! on the App Store on iTunes
Get Mental Arithmetic - train your brain! on the App Store. See screenshots and ratings, and read customer reviews.

Arithmetic Puzzle - Haskell live coding - YouTube
Live coding of Ruby Quiz 7 - Arithmetic Puzzle "Countdown" Unscripted, unedited, (uncut) - Haskell Uncut Read more at my blog post: http://c ...

Australia's deadliest sniper, Ian Robertson, 'never did the arithmetic'
The deadliest man in Australia comes from Melbourne, but he is not a gangster or a hitman. He is more a foxtrotting man, these days. He can do ...

Genetic anomaly could explain severe difficulty with arithmetic - The Science Show - ABC Radio National ...
... is that numbers are wired into the human brain and perhaps a genetic anomaly explains why some children have severe difficulties with arithmetic. ...

Help your kids master arithmetic with Monster Math 2
... upgrade to Monster Math 2 Pro and get access to new worlds, more advanced reporting, and all of the math skills. Help your kids master arithmetic ...

Price Drop: MencalHD:Mental Arithmetic Training,Improve Your Skills In Math
MencalHD:Mental Arithmetic Training,Improve Your Skills In Math 1.0 Device: iOS iPad Only Category: Education Price: Free, Version: 1.0 ( iTunes ...

Analysis: Republicans' budget plans require creative arithmetic to add up
Pittsburgh Post-Gazette Analysis: Republicans' budget plans require creative arithmetic to add up Bellingham Herald WASHINGTON — Republicans ...

"Here's America today... frivolous entertainment, texting and Twitter replacing serious news reporting ...
If only we weren't so frivolous , if we could get serious , maybe we could figure it all out.

Resources last updated: 2/29/2016 11:11:04 PM