Iteration in array of three columns and ten rows

2 次查看(过去 30 天)
Hi all, i have one question. I want to iterate in array follow the next steps:
i) First i analize one column and one row. The name of array with data is DNA and the name of outcome is "serial".
if true
% code
t=3 ;number of columns in array DNA
n= length(DNA)
for i=1:n
if DNA(i,1)==1 % if first column and "i" row is one, then the outcome row array is one
serial(i)=1;
elseif DNA(i,1)==-1 % if first column and "i" row is -1, then the outcome row array is -1
serial(i)=-1;
elseif DNA(i,1)==0 % Here i start to having doubts. If i have zero, i want analize the same row in % %column two
for j=2:t;
if DNA(i,j)==1 % i analize the same row and column two
serial(i)=1;
elseif DNA(i,j)==-1
serial(i)=-1;
elseif DNA(i,j)==0 % if i have zero in same row in column two, i want to analize the same %row in column three and look like my code is wrong...
end
I put the example with "i" arrows and three columns but my data is generic:
i=1,2,3,4.......n % rows j=1,2,3,4.......t % columns
How can i code this?
Thank you very much

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by