Filter löschen
Filter löschen

I can't get my function to work or print right

1 Ansicht (letzte 30 Tage)
Brendan
Brendan am 8 Nov. 2023
Beantwortet: Walter Roberson am 8 Nov. 2023
x=(0:31);
y=(2.^x);
disp(y)
Im just trying to get a list of values from 2^0 to 2^31. I know the range is right but I guess theres something I don't understand about functions because the values are mostly below 1.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Nov. 2023
The values are not below 1: you have been fooled by the way the default output format
x=(0:31);
y=(2.^x);
disp(y)
1.0e+09 * Columns 1 through 19 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0003 Columns 20 through 32 0.0005 0.0010 0.0021 0.0042 0.0084 0.0168 0.0336 0.0671 0.1342 0.2684 0.5369 1.0737 2.1475
format long g
disp(y)
Columns 1 through 7 1 2 4 8 16 32 64 Columns 8 through 14 128 256 512 1024 2048 4096 8192 Columns 15 through 21 16384 32768 65536 131072 262144 524288 1048576 Columns 22 through 28 2097152 4194304 8388608 16777216 33554432 67108864 134217728 Columns 29 through 32 268435456 536870912 1073741824 2147483648

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by