Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Column Operations Matlab

Subject: Column Operations Matlab

From: Donatello

Date: 26 Jun, 2010 03:19:04

Message: 1 of 3

i need create a function to chage the columns
example
1 2 3 3 2 1
4 5 6------------------------>6 5 4
7 8 9 9 8 7

this is my code:
function invier=cambifil(A)
[f,c]=size(A);

for i=1:f;
    for j=1:c;
       A(i,c-j+1)=B(i,j);
       B(i,j)=A(i,j);
        
    end
end
invier=A
    

Subject: Column Operations Matlab

From: Faraz Afzal

Date: 26 Jun, 2010 15:28:07

Message: 2 of 3

Dear Donatello,

Please try always to explain your problem clearly.

Anyways Here is your code..

function invier=cambifil(A)
[r,c]=size(A);
B = zeros(size(A));
for n=1:c
    B(:,n) = A(:,c-n+1);
end
B

for example you can use this matrix, (Making your life more easier)
A = [ 1 11 21
     2 12 22
     3 13 23
     4 14 24
     5 15 25
     6 16 26
     7 17 27
     8 18 28
     9 19 29]

Regards,
Muhammad Faraz

"Donatello " <Manguaco7@hotmail.com> wrote in message <i03rj8$i3p$1@fred.mathworks.com>...
> i need create a function to chage the columns
> example
> 1 2 3 3 2 1
> 4 5 6------------------------>6 5 4
> 7 8 9 9 8 7
>
> this is my code:
> function invier=cambifil(A)
> [f,c]=size(A);
>
> for i=1:f;
> for j=1:c;
> A(i,c-j+1)=B(i,j);
> B(i,j)=A(i,j);
>
> end
> end
> invier=A
>

Subject: Column Operations Matlab

From: us

Date: 26 Jun, 2010 17:17:05

Message: 3 of 3

"Donatello " <Manguaco7@hotmail.com> wrote in message <i03rj8$i3p$1@fred.mathworks.com>...
> i need create a function to chage the columns
> example
> 1 2 3 3 2 1
> 4 5 6------------------------>6 5 4
> 7 8 9 9 8 7
>
> this is my code:
> function invier=cambifil(A)
> [f,c]=size(A);
>
> for i=1:f;
> for j=1:c;
> A(i,c-j+1)=B(i,j);
> B(i,j)=A(i,j);
>
> end
> end
> invier=A
>

a hint:

     help fliplr;
     help flipdim;

us

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us