How do I convert decimals to exponents in a matrix?

18 Ansichten (letzte 30 Tage)
Deleted User am 9 Mai 2024
Bearbeitet: John Kelly am 20 Mai 2024 um 13:59
I am trying to generate a matrix with exponents (ie. (8)^5), but the numbers appear as decimals instead. How do I fix this?
This is the code I used:
A=[1 (2)^1 (2)^2 (2)^3 (2)^4 (2)^5 0.20;1 (5)^1 (5)^2 (5)^3 (5)^4 (5)^5 0.29;1 (8)^1 (8)^2 (8)^3 (8)^4 (8)^5 0.44;1 (11)^1 (11)^2 (11)^3 (11)^4 (11)^5 0.50;1 (14)^1 (14)^2 (14)^3 (14)^4 (14)^5 0.66;1 (20)^1 (20)^2 (20)^3 (20)^4 (20)^5 0.56]
B=rref(A)
2 KommentareKeine anzeigenKeine ausblenden
Stephen23 am 9 Mai 2024
Bearbeitet: Stephen23 am 9 Mai 2024

Numeric matrices do not store any formatting information.

What are you actually trying to achieve?:

https://xyproblem.info/

Deleted User am 9 Mai 2024
I am trying to generate a matrix with whole numbers, so that I can find the rref and then substitute the numbers into a polynomial equation.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pavan Sahith am 9 Mai 2024
Bearbeitet: John Kelly am 20 Mai 2024 um 13:59
Hello,
It seems you are trying to work with whole numbers and keep the results in an exact form (e.g., for symbolic computation or to avoid rounding errors), you might consider using symbolic math.
MATLAB's Symbolic Math Toolbox allows you to perform computations symbolically, keeping results in exact form rather than approximating them as floating-point numbers.
You can try something like this:
% Define the matrix symbolically
A = sym([1 (2)^1 (2)^2 (2)^3 (2)^4 (2)^5 0.20;
1 (5)^1 (5)^2 (5)^3 (5)^4 (5)^5 0.29;
1 (8)^1 (8)^2 (8)^3 (8)^4 (8)^5 0.44;
1 (11)^1 (11)^2 (11)^3 (11)^4 (11)^5 0.50;
1 (14)^1 (14)^2 (14)^3 (14)^4 (14)^5 0.66;
1 (20)^1 (20)^2 (20)^3 (20)^4 (20)^5 0.56]);
% Compute the reduced row echelon form symbolically
B = rref(A);
% Display the result
disp(B);
You can refer to the following MathWorks documentation to know more
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Linear Algebra finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by