user3466022
user3466022

Reputation: 145

Matlab: work with 2NxN matrix

I have a matrix 2NxN.

And I want get some parametrs by this matrix. For example it:

enter image description here How, I can do it?

Upvotes: 0

Views: 78

Answers (2)

Kassym Dorsel
Kassym Dorsel

Reputation: 4843

From what I understand here are the first three:

% Random Matrix
% Needs to be defined before the functions since the functions look for
% the m variable
m = rand(12,6);

% Function 1
p = @(i,j) sign(m(i,j)+m(i+1,j)) * max(abs(m(i,j)),abs(m(i+1,j)));
p(2,2)

% Function 2 - Avg of row
pavg = @(i) mean(m(i,:));
pavg(2)

% Function 3
c = @(i,j) abs(m(i,j)+m(i+1,j)) / (abs(m(i,j)) + abs(m(i+1,j)));
c(2,2)

Upvotes: 1

p8me
p8me

Reputation: 1860

You may want to break your 12x6 matrix, into two 6x6 matrix; let's say: Z and Zb (last one for z bar). Odd rows are Z and evens are Zb.

Considering M to be the combined matrices:

Z = M(1:2:end,:)
Zb = M(2:2:end,:)

read about the colon(:) operator and end to see what 1:2:end means.

Hope it helps.

Upvotes: 1

Related Questions