Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Prevent MatLab from Rounding the Values in a Matrix

Subject: Prevent MatLab from Rounding the Values in a Matrix

From: Kevin Ellis

Date: 16 Jun, 2011 05:00:20

Message: 1 of 4

Hello,

In MatLab I have created a 5x5 matrix where in each entry there is a specific equation with different variables. The equations in entry range greatly in terms of the calculated values. For example one entry will be equal to 10.3468 and the next entry will be equal to 5.391106*10^-6. Now the problem I am having is that when I create the matrix using variables inside the matrix the values that are output are rounded off. The entry in the matrix that was equal to 10.3468 displays perfectly, but the entry that was equal to 5.391106*10^-6 simply shows zero. Thus my question is if there is a way to make MatLab, when calculating the matrix, output these small values instead of rounding to zero? I have tried using 'double' but with no luck. I would like to get a matrix with values that are in a format similar to what you would see on a TI-83. Thanks for the help, sorry if the question is
confusing.

Kevin

Subject: Prevent MatLab from Rounding the Values in a Matrix

From: Rune Allnor

Date: 16 Jun, 2011 05:09:25

Message: 2 of 4

On Jun 16, 7:00 am, "Kevin Ellis" <kevin.elli...@gmail.com> wrote:
> Hello,
>
> In MatLab I have created a 5x5 matrix where in each entry there is a specific equation with different variables. The equations in entry range greatly in terms of the calculated values. For example one entry will be equal to 10.3468 and the next entry will be equal to 5.391106*10^-6. Now the problem I am having is that when I create the matrix using variables inside the matrix the values that are output are rounded off. The entry in the matrix that was equal to 10.3468 displays perfectly, but the entry that was equal to 5.391106*10^-6 simply shows zero. Thus my question is if there is a way to make MatLab, when calculating the matrix, output these small values instead of rounding to zero? I have tried using 'double' but with no luck. I would like to get a matrix with values that are in a format similar to what you would see on a TI-83. Thanks for the help, sorry if the question is
> confusing.
>
> Kevin

doc format
doc sprintf

Rune

Subject: Prevent MatLab from Rounding the Values in a Matrix

From: Krishna Kumar

Date: 16 Jun, 2011 05:15:05

Message: 3 of 4

"Kevin Ellis" wrote in message <itc2l4$aks$1@newscl01ah.mathworks.com>...
> Hello,
>
> In MatLab I have created a 5x5 matrix where in each entry there is a specific equation with different variables. The equations in entry range greatly in terms of the calculated values. For example one entry will be equal to 10.3468 and the next entry will be equal to 5.391106*10^-6. Now the problem I am having is that when I create the matrix using variables inside the matrix the values that are output are rounded off. The entry in the matrix that was equal to 10.3468 displays perfectly, but the entry that was equal to 5.391106*10^-6 simply shows zero. Thus my question is if there is a way to make MatLab, when calculating the matrix, output these small values instead of rounding to zero? I have tried using 'double' but with no luck. I would like to get a matrix with values that are in a format similar to what you would see on a TI-83. Thanks for the help, sorry if the question is
> confusing.
>
> Kevin
Hi Kevin,
          Your question is really confusing. Perhaps changing format to 'long' might help you. Also tell us if the output was simply 0 are 0.000 etc.Please explain your problem clearly!
hth,
Krishna.

Subject: Prevent MatLab from Rounding the Values in a Matrix

From: Roger Stafford

Date: 16 Jun, 2011 05:39:05

Message: 4 of 4

"Kevin Ellis" wrote in message <itc2l4$aks$1@newscl01ah.mathworks.com>...
> .... The entry in the matrix that was equal to 10.3468 displays perfectly, but the entry that was equal to 5.391106*10^-6 simply shows zero. ......
- - - - - - - - - -
  What Rune and Krishna are telling you, Kevin, is that your matrix values have remained just as they were when entered. They have not been rounded any further after entry (unless of course if you have subsequently modified them.) It is only the display of them that is giving you misleading notions about their values. Set "format long" and trying displaying individual elements of the matrix to see that this is true.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us