Write a script to create a matrix B equal to A, but with its last column equal set to 0.

5 ビュー (過去 30 日間)
Can someone help with a hint of this question using MATLAB?
Write a script to create a matrix B equal to A, but with its last column equal set to 0.

採用された回答

chicken vector
chicken vector 2023 年 4 月 7 日
編集済み: chicken vector 2023 年 4 月 7 日
I suppose you want to limit your case to bi-dimensional arrays.
You can create a function which works for every matrix
function A = createCopyWithNullLastColumn(A)
% Change values of last column :
A(:,end) = 0;
end
Or go with the script:
% Create random matrix <A>:
A = rand(randi([1,10]), randi([1,10]));
% Create a copy <B> of <A>:
B = A;
% Set last column of <B> equal to <0>:
B(:,end) = 0;
  1 件のコメント
John D'Errico
John D'Errico 2023 年 4 月 7 日
編集済み: John D'Errico 2023 年 4 月 7 日
Please don't do obvious homework assignments for students. This never helps the student, who learns nothing more than they can find someone willing to do their work for them, if they only plead sadly enough.
It does not help the site, since it convinces that student to continue to post their homework assignments, with no effort made.
Worse, it actively hurts the site, because then it convinces other students they have the right to post their homework assignments too. You then help to turn answers into a site where nothing is seen except for students angrily demanding that we do their homework for them, and do it quickly.
If you feel compelled to help, then offer some guidance. Push them in the right directino. Here, you might have suggested they create a smaller random matrix, and then append zeros, or something like that, but NOT write the code for them.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by