Removing a column from any sized array help!!

7 ビュー (過去 30 日間)
Alex Platt
Alex Platt 2020 年 4 月 2 日
編集済み: Alex Platt 2020 年 4 月 2 日
HI there, so i am stuck again on trying to get a line of code in order to remove the 3rd column from any sized array in matlab by using a function. My current code is as follows. I looked up how to remove columns and I can do it but when using a function it gets messed up and doesnt work. It should only be one line of code to the right of the 'Z =' portion. I have included the quesstion as well in the image attatched. I have tried Z(:,3) = [] and it doesnt work. I also tried Z(A(:,3)) = [] and it aslo didnt work so now I am quite lost. Thank you!!
function Z = remove3(A)
Z = A(:,3);
end

回答 (1 件)

Image Analyst
Image Analyst 2020 年 4 月 2 日
Hint:
m = magic(4)
m(:,3) = []
  1 件のコメント
Alex Platt
Alex Platt 2020 年 4 月 2 日
The grader I have says that is incorrect for this particular problem. I gave this code a try earlier and had no luck. I think it only wants code on the right side of the 'Z =' or in your case the 'm = '.But thank you for the answer either way.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by