Matrix Manipulation Using Matlab Looping Function

Matrix manipulation is the power of Matlab. That’s why Matlab stands for Matrix Laboratory (not Mathematics laboratory). This software easily calculates many Matrix operation that difficult for other languages (c++, java, etc.). In addition, Matlab not only operates through its function but also uses looping tools similar to other language, i.e. ‘for-next’, ‘while-do’, etc. One of my best friends studying in Australia discussed about how to manipulate Matrix efficiently weeks ago. For example we have a matrix:

And we have another matrix, B=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15];

The question is how to create matrix C which contains column elements in B for every even number of column in A. Of course we can create manually based on the B value, but the problem is when the number of Matrix A and B are thousands, e.g. coordinates. In Matlab we are allowed to use “for-next” instruction to manipulate a matrix.

  • >> C=A;
  • for i=1:10
  • [rows cols]=size(B);
  • if cols>=i
  • C(:,2*i)=B(:,i);
  • end
  • end

The script will give the result:

Use function “size” to know maximum column of A and B. Of course you can try to create the other algorithms for this purpose. Tq

Tentang rahmadya

I'm a simple man .. Lahir di Sleman Yogyakarta, 7 Juni 1976 PENDIDIKAN: TK : - (tidak ada TK di tj Priok waktu itu) SDN : Papanggo, Jakarta 83 - 89 SMPN : 129, Jakarta 89 - 92 SMAN : 8, Yogyakarta 92 - 95 Univ. : Fak. Teknik UGM, Yogyakarta 95 - 2001 Pasca. : Tek. Informatika STMIK Nusa Mandiri, Jakarta 2008 - 2010 Doctoral : Information Management Asian Institute of Technology, Thailand 2013 - 2018 PEKERJAAN: Tek. Komputer AMIK BSI Jakarta : 2002 - 2005 IT Danamon Jakarta : 2005 - 2008 Tek. Informatika STMIK Nusa Mandiri Jakarta : 2005 - 2008 Univ. Darma Persada Jakarta: 2008 - 2013 Fakultas Teknik Universitas Islam "45" Bekasi : 2008 - Skrg ( Homebase) Univ. Bhayangkara Jakarta Raya: 2018 - Skrg Univ. Nusa Putra Sukabumi: 2018 - Skrg
Pos ini dipublikasikan di Matlab. Tandai permalink.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.