Soyol
Soyol

Reputation: 793

Matlab: How to decrease the precision of calculations in matlab to let's say 4 digits?

I am wondering what would be the way to tell Matlab that all computations need to be done and continued with let's say 4 digits.

format long or other formats I think is for showing the results with specific precision, not for their value precision.

Upvotes: 1

Views: 216

Answers (2)

horchler
horchler

Reputation: 18504

Are you hoping to increase performance or save memory by not using double precision? If so, then variable precision arithmetic and vpa (part of the Symbolic Math toolbox) are probably not the right choice. Instead, you might consider fixed point arithmetic. This type of math is mostly used on microcontrollers and architectures with memory address widths of less than 32 bits or that lack dedicated floating point hardware. In Matlab you'll need the Fixed Point Designer toolbox. You can read more about the capabilities here.

Upvotes: 2

Serenity
Serenity

Reputation: 36705

Use digits: http://www.mathworks.com/help/symbolic/digits.html

digits(d) sets the current VPA accuracy to d significant decimal digits. The value d must be a positive integer greater than 1 and less than 2^29 + 1.

Upvotes: 1

Related Questions