フィルターのクリア

Please answer all. it is related to Numerical linear Algebra

3 ビュー (過去 30 日間)
Kashk
Kashk 2023 年 10 月 5 日
編集済み: Rena Berman 2023 年 11 月 27 日
answer Numerical linear Algebra
  4 件のコメント
Sam Chak
Sam Chak 2023 年 10 月 5 日
@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 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 件のコメント
Walter Roberson
Walter Roberson 2023 年 10 月 5 日
function cannot be declared at the command line.
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 Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by