Problem 7. Column Removal

I don't know why my answer is wrong but please tell me..
function B = column_removal(A,n)
A=A(:,[1:n-1 n+1:end]);
haha=size(A);hasil=[];
A=A';
A=A(:)';
B =A;
end

1 件のコメント

Jan
Jan 2013 年 7 月 14 日
@ricardo: In general it is a good idea when you ask in the forum, that you explain, why you assume, that there is an error. E.g. post the complete message, if you get an error, or explain the difference between your expectations and the results. Relying of the power of the forum users to guess the problem works sometimes only.

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

 採用された回答

Image Analyst
Image Analyst 2013 年 7 月 14 日

1 投票

Simply set that column to null to remove it:
function B = column_removal(A,n)
B = A; % Initialize.
B(:, n) = [];
Isn't that what you saw as the correct answer?

3 件のコメント

ricardo gunawan
ricardo gunawan 2013 年 7 月 14 日
編集済み: ricardo gunawan 2013 年 7 月 14 日
wew thx for answering but i want to ask
at line 2 there is B=A; that line is going terminate the function is it?
my previous programming is c++
Image Analyst
Image Analyst 2013 年 7 月 14 日
No it's not. The function terminates when
it hits the end of the file, or
it hits an "end" statement, or
it hits another "function" statement, or
it hits a "return" statement.
Jan
Jan 2013 年 7 月 14 日
@ricardo: The basics of Matlab are explained in the Getting Started chapters of the documentation. It is more efficient to read them than to ask the forum to retell it.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 14 日

0 投票

There is no error in your code. What is the expected result?
If you want to remove a column number n
A=magic(5) % Example
n=3 % column to be removed
Result=A;
Result(:,n)=[]

3 件のコメント

ricardo gunawan
ricardo gunawan 2013 年 7 月 14 日
I think to much for easy problem wkwkw....
(~‾ ▽‾)~
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 14 日
What?
Jan
Jan 2013 年 7 月 14 日
@ricardo: Neither wkwkw nor the fancy character thing is useful here. We are interested in Matlab, but not cool.

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

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by