f

#### Basic Matlab question?

```1. Why isn't 3 divided by 2 equal 1.5 in matlab?

2. In matlab, why is 2/3 equal to 0? Isn't 2/3 equal to 0.667?
```
 0
Thomas
10/1/2010 4:51:04 AM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader.

4 Replies
1297 Views

Similar Articles

[PageSpeed] 20

```That's what my Matlab says :)

>> 2/3

ans =

0.6667

>> 3/2

ans =

1.5000

So what exactly is your problem?
```
 0
martin
10/1/2010 5:12:05 AM
```the answers are not abnormal in matlab. try it again properly.

"Thomas Cruz" <tcruz1@unm.edu> wrote in message <i83pbo\$dhl\$1@fred.mathworks.com>...
> 1. Why isn't 3 divided by 2 equal 1.5 in matlab?
>
> 2. In matlab, why is 2/3 equal to 0? Isn't 2/3 equal to 0.667?
```
 0
10/1/2010 5:45:31 AM
```"martin Müllinger" <zettinger@gmx.de> wrote in message <i83qj5\$5uq\$1@fred.mathworks.com>...
> That's what my Matlab says :)
>
> >> 2/3
>
> ans =
>
>     0.6667
>
> >> 3/2
>
> ans =
>
>     1.5000

However,

>> int32(3)/2
ans =
2

In C you'd get 1. Integer arithmetic is not done with integers in MATLAB... :)

Cris.
```
 0
Cris
10/1/2010 8:07:05 AM
```
"Thomas Cruz" <tcruz1@unm.edu> wrote in message
news:i83pbo\$dhl\$1@fred.mathworks.com...
> 1. Why isn't 3 divided by 2 equal 1.5 in matlab?

It should be, unless (as some of the other posters have guessed) one or both
of your 2 or 3 are actually stored using an integer data type:

disp(3/2)
disp(int8(3)/2)
disp(3/uint16(2))

> 2. In matlab, why is 2/3 equal to 0? Isn't 2/3 equal to 0.667?

See above.  This behavior is documented:

http://www.mathworks.com/help/techdoc/matlab_prog/f2-12135.html#f2-98095

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
http://www.mathworks.com

```
 0
slord (13689)
10/4/2010 3:51:42 PM

Similar Artilces:

matlab basic questions
Hi, Pretty new to matlab and also to signal processing. I have few basic questions. Would appreciate if someone answers them ... 1) Is matlab used only for analysis? Can I design a filter and then export the complete design in c 2) I saw that one of the tutorial on filter and it seems to export mainly co-efficients, parameters of a filter. But what about the algorithm in C that is used to process the input? Do we have to write them on our own. 3) Some of the advanced functions like image processing have in build functions. If I wanted to create a standalone function outside of matlab,...

basic questions in matlab
Hello, I am new in matlab and i would like help to understand the next lines: ////////////// for n=1:npanels cmn=ffil(rc(:,n),r(:,nw),r(:,sw))+ffil(rc(:,n),r(:,sw),r(:,se))+ffil(rc(:,n),r(:,se),r(:,ne))+f coef(n,:)=nc(1,n)*cmn(1,:)+nc(2,n)*cmn(2,:)+nc(3,n)*cmn(3,:); end //// At this i understand that build a matrix coef(npanels,npanels) rm=(-nc(1,:)*vinf(1)-nc(2,:)*vinf(2)-nc(3,:)*vinf(3))'; //// Build a vector rm(npanels) coef(end+1,:)=1;rm(end+1)=0; %prevents singular matrix - sum of panel strengths on closed body is zero //// Add a new row to prevent singularity, so my question i...

Basic matlab question
It is an easy question I guess but I need help I have three columns: day, hour and data exemple: 1 4 22 1 8 120 1 12 510 1 17 245 2 3 37 2 10 311 3 14 362 3 18 131 3 21 26 I have another table with max and min hour for each day and I would like to keep just the data between that max and min and transform the rest in NaN. Each day have different number of data. Can anyone help me? On Aug 20, 12:51=A0pm, Fabian <fabianbat...@hotmail.com> wrote: > It is an easy question I guess but I need help > I have three columns: day, hour and data > exemple: &...

MatLab Basics Question
Hello. I'm extremely new to MatLab. I'm a student... and I have an assignement that requires me to use it. No, I'm not asking for "Can someone do my homework?" I need help with the basics. My professor gave my class a 5 minute tutorial, and then gave us this crazy assignment.. and I'm lost. How do I set up the following in MatLab? I have no clue... The S-MF with two parameters l and r (l<r) is an S-shaped open-right Membership FUnction defined by: | 0, for x<= 1, S(x;l,r))= ---+ 2((x...

How does matlab work in this issue ? a matlab principle question
Hello everyone I have an ODE solver computing the temperature every month during a year this script will do the job for j=1:12 [t,T]= ode45(@monthly_solver,tspan,Tic,[],monthly_heat(j),h2(j),); end where Tic is the intial temperature and J loops represents the months Now the question is about matlab principle and how does it work with the initial condition? i mean as the last temperature of the 1st month is the begining temperture of the 2nd month and the last temp. of the 2nd month is the begining temp. of the 3rd month and so on. Do i need to write a command to do ...

Matlab Architecture Question
I am interested in hearing ideas about the best ways to create "modules" in matlab? The goal is to have one interface, where I can easily switch routines, and have different versions of the routine run. For example, suppose I have a routine to recognize license plates. It needs to be initialized, and then on subsequent calls it needs to be run. Later one, I want to swap the license plate recognition file, with another one, and have the new one take effect. Is there an established 'best practice' for this in Matlab? - Pat [ I'm upgrading to Matlab 2009a, from 2005&...

Plots in MATLAB
Dear all, I am attempting to plot the yaw velocity gain for an automobile system in MATLAB. This is straightforward - just an equation to calculate it and then plotting G_yvg on the y-axis against v_x on the x axis. I would like my values for v_x to be from 5 to 50. I attempted to run the code below: -- Code start -- % Bicycle Model for car A - The understeer car m = 1669; I_z = 3144; l_F = 1.178; l_R = 1.567; l = l_F + l_R; C_F = 59410; C_R = 50730; K_us = 9.409*10^-3; g = 9.81; v_x = 5:1:50; % This needs to be values between 5 and 50 G_yvg = v_x/l+(K_us*v_x^2/g); ...

I have a matlab 7.0.1 on windows xp machine, and I was trying to learn guide from the example in the manual, basically there are three push buttons in a panle to choose the type of graph (surf, contour, mesh) and a pop up menu to choose different data, and a axis. I've encountered strange problems. The first time when I finish the gui design and test it, the figure (axis) does not show up, also push buttons are covered by the panel and can not be seen. I have set figure visible. Then I decided to start over, this time I were able to see all the components initially, but after I choose c...

Basic question on DLLs in Matlab
Does anybody know a good tutorial about how to implement DLLs written in C++ in Matlab? I'm also a beginner in C++, so I practically don't know anything about how to write a DLL (apart from some very basic introduction). I'd be especially interested in how to include functions in the DLL, and how to call them in Matlab. Can be as simple as a standard IO-command. Any help is welcome, so as to get an idea how this works fundamentally. ...

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...

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...

Hello! I'm working in Simulink. When you open a Simulink avaiable demo, they have a workspace associated and small block called "info" that opens a help file of the demo (for example, the commdvbt.mdl - DVBT 2k Nonhierarchical Transmission). I have 2 basic questions: 1st - I have changed the demo and the ".m" file associated to another directory.. and I'm getting the following message: Warning: Workspace for block diagram 'commdvbt' was not loaded because an error occurred while loading M-Code: 'commdvbt_tablegen'. Previously accessible file &quo...

Basic Matlab Question #3
I have a 32 x 1300 2D array, lets call it S. I know I can pick off a particular row with the following argument: A = S(1,:); which gives me a 1 x 1300 array from the first row of the 2D array. I want every row assigned to a new indexed array, so I would start off with for n = 1:rows A(n) = S(n,:); end This doesn't work because of a dimensional mismatch. I'm not really trying to define a dimension but simply declare a unique identifier. How am I able to assign rows such that I can put them in A(1), A(2), etc., all with the dimension 1 x 1300. Thanks! On Nov 16, 3:46=A0pm, ...

Hi! I am a newbie in case of artificial neural networks. Please answer simple ;-) I need to implement digit classification (OCR) with numbers 0..9 as output and approx. 3800 training images. I also have ~1800 test images. I found the OCR example shipped with Matlab and played with it. It uses a feedforward NN with backpropagation (newff). Here my questions: How can I determinate the optimal number of training images? If I use 3800 it takes some time to train. I played with subsets of 200, 400, 500, 800 images and the results where not linear increasing. Should I "re-train"...

basic MATLAB question #2
I have a script where I input specific columns from a ascii file and perform a function on them. Is it possible to set the name, of the file I import, as some kind of variable so that I don't have to write the filename over and over for each time I import it? This is how I do it now: x = dlmread('asciifile', '\t', 'A1..A100'); y = dlmread('asciifile', '\t', 'B1..B100'); I want to be able to do something like this: filename = 'asciifile' x = dlmread('filename', '\t', 'A1..A100'); y = dlmread('filename&#...

Some basic questions about MATLAB operation
Hi, I have recently started using MATLAB for a DSP and a Communication Theory class. I have some questions about how MATLAB does some things. 1. To plot a graph, say a sinusoid, I always do this: t=0:.1:10; a=sin(t); plot(t,a) What does MATLAB do to generate the data for the points that are not in increments of .1? for example sin(1.13)? Does it interpolate to generate the graph? Is this sinusoid only valid for .1 increments? In fact, a function in MATLAB is inherently discrete, but we use it to model continuous functions (its 'domain' is actually only 101 samples)? 2. I'm having...

Slope related basic MATLAB question
Dear all, I need to write a small program which to test whether a line (position vector) does strictly clockwise or CCLW movement. I tried to use atand to find the angle, but it could jump from negative to positive value when it pass thought 90 deg, it will have the same thing if I use slope method. However, the motion does not have to cut at 90 deg, it could jump from 89 to 91. Then a big slope jump could happen. Any idea please Thanks ...

Hi everybody, I wrote this code in matlab solve('a-2=0') matlab wrote: ans = 2 this means that a is equal to 2. But when I write a matlab wrote: a but matlab must know that a =2 . But I think it doesn't match. It doesn't know that a is equal to 2. How can I write the code? Thanks "a.s" <erkenays@yahoo.com> wrote in message news:ef1aa19.-1@webx.raydaftYaTP... > Hi everybody, > > I wrote this code in matlab > > solve('a-2=0') > > matlab wrote: > > ans = > 2 > > this means that a is equal to 2. No, it does n...

CONDOR MATLAB WINDOWS: Basic Question
I am running 2009a Matlab and 2010 matlab on Windows Vista. I have a large number of Dell dual core machines each running windows vista. I have some complicated code which can be parallelized/ distributed. Essentially the code boils down to a large number of independant for loops, each loop carrying out a job (ie the outcome of any given job is independant of any other job). n is large. for i = 1:n myFunc() end I wish my loop to finish (much) faster. Ideally I will not have to install matlab on each machine. I would like each call to myFunc to be sent off to a node. D...

**** Misc. question for Matlab Basics **** Must see----
hi everyone need ur help for following questions. 1. can we make EXE in Matlab? how? 2. How can we make SETUP of the project? 3. Can we connect our database (microsoft access or ms excel or other form) with .m file in matlab? if no then how can we use database in matlab.? 4. Can we generate reports from the database using matlab application. 5. can anyone fillup this tables and give me equations for images taken for study purpose? magification Pixel mm 20x 1 ? 40x 1 ? 60x 1 ? 80x 1 ? 100x 1 ? if yes then how? reply me soon because i need it urgently.. you can mail me also dhaval_patel_1@yahoo.com, dhaval4friends@indiatimes.com, Regards Dhaval Dhaval Patel wrote: > > > hi everyone > need ur help for following questions. > > > 1. can we make EXE in Matlab? how? yes, with matlab compiler (help mcc) > > 2. How can we make SETUP of the project? > > 3. Can we connect our database (microsoft access or ms excel or > other > form) with .m file in > matlab? if no then how can we use database in matlab.? yes, use matlab database toolbox (if you have), it is very well documented. > > 4. Can we generate reports from the database using matlab > application. > > 5. can anyone fillup this tables and give me equations for images > taken for study purpose? > > > magification Pixel mm > > > 20x 1 ? > 40x 1 ? > 60x 1 ? > 80x 1 ? > ...

looking for help (I think its a basic MATLAB question)
I am very new to MATLAB and looking for some help. If anyone could please help me I would really appreciate it. I'm trying to set up a program to do rainflow counting. I wanted to start with a very simple example and add more to it. At this point this is not considered rainflow counting. I want the program to go through the vector and eliminate one part of the vector at a time. When I set p=1 in the for-loop, I am trying to get the loop to start from the very beginning again, rather than increase the i. Any suggestions? Thanks in advance! -Shaun clc clear all x= [20 30 -40 50 20 ...

Hi everybody, I wrote this code in matlab solve('a-2=0') matlab wrote: ans = 2 this means that a is equal to 2. But when I write a matlab wrote: a but matlab must know that a =2 . But I think it doesn't match. It doesn't know that a is equal to 2. How can I write the code? Thanks a = solve('a-2=0') and the help-function in matlab helps really ;-)) Slash ...

Importing multiple text files into MATLAB (basic question)
Hi All, I recently started a summer job, and was hoping that someone on this forum could provide me with a little assistance. I've used MATLAB in the past in a numerical analysis class, but do not have all that much experience yet. I have a data set consisting of around 50 text (.txt) files. Each text files contains multiple matrices. An example of how one of these matrices is formatted follows: "Gazepoint Trace Data File, 09:46:08 03/05/2002 22 Scene Type: text 1024 768 C:\Eyegaze\penguin.txt Raw Gazepoint Data (60 Hz Sampling Rate): samp Eye Gazepoint Pupil Eyeball-...

Some questions on matlab
Hi all, i am using matlab and encountered some problems. Kindly advice. 1)i am using newff function to create a neural network.After which, someone advised me to set some of the parameters ,for example, net.performFcn,net.trainParam.goal and many more. But i tried using my matlab help and search for function to llok up for what these parameters do. However, i can't find any help on these parameters. Where can i find them? 2)i intend to use the train function to train my network. In the train function, according to the help file,we can also give T(network targets) as input. Can someone ki...

Web resources about - Basic Matlab question? - comp.soft-sys.matlab

German question - Wikipedia, the free encyclopedia
"Kleindeutschland" redirects here. For the neighborhood in New York City, see Little Germany, Manhattan . 1820 map of Central Europe showing ...

Filed under: Government/Legal , Driving , Racing It's laughably easy to get a driver's license in the USA. Should we require all drivers to complete ...

Comey: Dispute between FBI, Apple "hardest question I've seen in government"
CBS News Comey: Dispute between FBI, Apple "hardest question I've seen in government" CBS News FBI Director James Comey on Thursday told Congress ...

FBI Director: Apple, FBI Dispute Is ‘Hardest Question I’ve Seen In Government’
'The San Bernardino litigation isn't about trying to set a precedent or send any kind of message'

Questions here! Leave your Podtoid questions here!
In 60 short minutes we'll be recording another episode of everyone's beloved family programming, Podtoid. We endeavor to make every subsequent ...

Question of the Day: Do You Use Google Now on Tap?
At Google I/O last year, one of the highlights of the entire show was without a doubt the demo for Google Now on Tap . During the brief performance, ...

Khloe Kardashian Shows Off Rock Hard Abs on Instagram, Fans Question If Pic Was Altered
Uh oh! The reality TV star may have just found herself in another social media dilemma.

Oscars 2016: 5 burning questions
CBS News Oscars 2016: 5 burning questions Entertainment Weekly Voting ended Tuesday night. Campaigning is complete. All everyone can do now ...

Foxconn Delaying Sharp Takeover as Questions Arise About the Deal
Questions about Sharp's financial liabilities and future financial risks are holding up the deal, which was slated to be signed this month.

Artist Toyin Ojih Odutola Explores and Questions the Construct of Blackness
Toyin Odutola is uniquely aware of how perceptions of the artist can alter the perceptions of the artwork, and not always for the better. Though ...

Resources last updated: 2/26/2016 1:41:14 AM