How do I store larger and smaller values in a matrix?

4 views (last 30 days)
Hi!
I made a small code and found out that when making calculations in my matrix some values approximates to zero as a result of other large numbers. Is there some general way of managing this? Here's my code:
R = 100;
C = 10^-9;
R3 = 100;
R2 = ones(3,1).*R3.*sqrt(2)
R2(1) = 1 *R2(1); %Equal complex and real part
R2(2) = 0.95 *R2(2); %Larger complex than real part
R2(3) = 1.05 *R2(3); %Smaller complex than real part
R4 = 100;
R5 = 100;
G = R5/R4;
k = G/(R*C);
%Transfer fucntion numerator and denumerator
denum = ones(3,3);
for i = 1:3
denum(i,:) = [1, k.*R2(i)./R3, k^2]
end
You will se that all rows in denum's first column will become 0 as k^2 is large. Even though the first column should have ones in it.
I know I can but in ones later on, but I have ones there for the simplicity of explaining the problem.

Accepted Answer

OCDER
OCDER on 2 Oct 2017
I'm guessing this is what you see:
denum =
1.0e+014 *
0.0000 0.0000 1.0000
0.0000 0.0000 1.0000
0.0000 0.0000 1.0000
This is just the way matlab displays variables, but the value is still there. To see all the variables, use the format function like this:
>> format longeng
or
>> format shorteng
your denum values is now this (shorteng version):
denum =
1.0000e+000 100.0000e-006 100.0000e+012
1.0000e+000 13.4350e+006 100.0000e+012
1.0000e+000 14.8492e+006 100.0000e+012

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!