Effacer les filtres
Effacer les filtres

Please answer all. it is related to Numerical linear Algebra

3 vues (au cours des 30 derniers jours)
Kashk
Kashk le 5 Oct 2023
Modifié(e) : Rena Berman le 27 Nov 2023
answer Numerical linear Algebra
  4 commentaires
Sam Chak
Sam Chak le 5 Oct 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 le 5 Oct 2023
Modifié(e) : John D'Errico le 5 Oct 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.

Connectez-vous pour commenter.

Réponses (2)

Sam Chak
Sam Chak le 5 Oct 2023
Modifié(e) : Sam Chak le 9 Oct 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 commentaires
Walter Roberson
Walter Roberson le 5 Oct 2023
function cannot be declared at the command line.
Sam Chak
Sam Chak le 6 Oct 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"

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 5 Oct 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 commentaires
Torsten
Torsten le 5 Oct 2023
Modifié(e) : Torsten le 5 Oct 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 le 5 Oct 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur Performance and Memory dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by