Please answer all. it is related to Numerical linear Algebra

3 次查看(过去 30 天)
answer Numerical linear Algebra
  4 个评论
John D'Errico
John D'Errico 2023-10-5
编辑:John D'Errico 2023-10-5
@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.

请先登录,再进行评论。

回答(2 个)

Sam Chak
Sam Chak 2023-10-5
编辑:Sam Chak 2023-10-9
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 个评论
Sam Chak
Sam Chak 2023-10-6
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"

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2023-10-5
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 个评论
Torsten
Torsten 2023-10-5
编辑:Torsten 2023-10-5
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 2023-10-5
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Performance and Memory 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by