Borrar filtros
Borrar filtros

Please answer all. it is related to Numerical linear Algebra

3 visualizaciones (últimos 30 días)
Kashk
Kashk el 5 de Oct. de 2023
Editada: Rena Berman el 27 de Nov. de 2023
answer Numerical linear Algebra
  4 comentarios
Sam Chak
Sam Chak el 5 de Oct. de 2023
@Kashk, Then you can do it over here:
Learning to construct a function from this example should be sufficient for you to handle the rest, I guess!
John D'Errico
John D'Errico el 5 de Oct. de 2023
Editada: John D'Errico el 5 de Oct. de 2023
@Kashk - that you want someone to do your homework is not relevant. It is yours. You will learn by doing. Anwers is not a service to solve homework problems. I closed your other questins, and I will now be more diligent in closing your questions if posted like this, with no effort made.
And, if this really is just a practice question, then you don't really need to solve it in the first place. I will note that your other questions wee posted with demands that someone do them for you.

Iniciar sesión para comentar.

Respuestas (2)

Sam Chak
Sam Chak el 5 de Oct. de 2023
Editada: Sam Chak el 9 de Oct. de 2023
In reference to your posted exercise concerning the definition of MATLAB functions, I'd like to provide a straightforward example illustrating the creation of a function that yields a singular matrix of size . The "Singular Matrix" example, though informative, does not directly address any of the six questions posed in your exercise.
To comprehensively address these inquiries, you must delve into the properties of various special matrices, including the Symmetric Matrix, Invertible Matrix, Lower Triangular Matrix, Upper Triangular Matrix, Random Matrix, as well as the Booleam Matrix.
For additional guidance and exemplification, you may also peruse a selection of examples available via the following link: https://www.mathworks.com/help/matlab/ref/function.html.
Example for creating a Singular Matrix using a Function file.
Refer to Step 1 first, and then come back to Step 2.
Step 2: Call the function from the command line >>.
% -------------------------------------------------
% Ignore these 3 lines first. You need to create the function file.
% After saving the file, type these 3 lines on MATLAB Command Window.
% -------------------------------------------------
n = 3;
A = SingularMat(n)
A = 3×3
1 1 1 1 1 1 1 1 1
tf = logical(rank(A) < n) % Test if matrix is singular (1:true, 0:false)
tf = logical
1
Step 1: Create the function file.
% -------------------------------------------------
% Type the code in the MATLAB Editor and then
% save the file using the same name, "SingularMat.m",
% in the current folder or in a folder on the MATLAB search path.
% -------------------------------------------------
function M = SingularMat(n) % Declares a function named SingularMat that accepts input n and returns output M
% This function creates a singular matrix of size n×n
% For more info, see https://www.mathworks.com/help/matlab/ref/ones.html
M = ones(n);
end
  3 comentarios
Walter Roberson
Walter Roberson el 5 de Oct. de 2023
function cannot be declared at the command line.
Sam Chak
Sam Chak el 6 de Oct. de 2023
Hi @Kashk,
Follow the step-by-step instructions below and you will be able to say "Hello" to the world of "Functions".
Step 1: Select the "Function" cell in the drop-down list
Step 2: A template of a Function will be shown under the Editor tab.
Step 3: Write the Function file as guided on this forum thread.
Step 4: Save the Function file to the current folder.
Step 5: Save Function file as "SingularMat.m" (by default).
Step 6: If the file is saved correctly, you will notice that "untitled" is now named "SingularMat.m".
Step 7: In the Command Window, call the function "SingularMat(n)" to produce an output assigned to "A"

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 5 de Oct. de 2023
The identity matrix is simultaenously real, non-singular, upper triangular, and lower triangular. So code that constructs an n x n identity matrix would satisfy the first four questions.
  3 comentarios
Torsten
Torsten el 5 de Oct. de 2023
Editada: Torsten el 5 de Oct. de 2023
You don't know how to generate the n x n identity matrix ?
In this case I recommend a 2-hours online course in MATLAB for free:
Walter Roberson
Walter Roberson el 5 de Oct. de 2023
lookfor identity matrix
eye - Identity matrix speye - Sparse identity matrix Identity Matrix - Generate matrix with ones on main diagonal and ground values elsewhere eye - Create identity matrix with fixed-point properties codistributed.speye - Create codistributed sparse identity matrix distributed.speye - Create distributed sparse identity matrix codistributed.eye - Create codistributed identity matrix

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by