Please answer all. it is related to Numerical linear Algebra
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
answer Numerical linear Algebra
4 comentarios
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.
Respuestas (2)
Sam Chak
el 5 de Oct. de 2023
Editada: Sam Chak
el 9 de Oct. de 2023
Hi @Kashk
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)
tf = logical(rank(A) < n) % Test if matrix is singular (1:true, 0:false)
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
el 5 de Oct. de 2023
function cannot be declared at the command line.
If you are using LiveScript then see https://www.mathworks.com/help/matlab/matlab_prog/create-live-functions.html
Sam Chak
el 6 de Oct. de 2023
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"
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.
Ver también
Categorías
Más información sobre Performance and Memory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!