필터 지우기
필터 지우기

Wants to add each iteration data in the next column.

조회 수: 3 (최근 30일)
shobhit pipil
shobhit pipil 2020년 2월 6일
편집: shobhit pipil 2020년 2월 11일
x=rch;
flow=rch(:,8);
c=0;
for i=1:166 %c=c+1
for c=c+1 %c<166
ind1 = rch(:,2) == c;
flow_out2= flow(ind1);
end
% xlswrite('out.xlsx', flow_out2','A1:FJ2191')
flow_out2 = [flow_out2 dataToAppend];
end
  댓글 수: 8
shobhit pipil
shobhit pipil 2020년 2월 6일
how do I control for loop in the code.
for c=c+1 % is it valid
if not, how do I control this loop?
thanks
Rik
Rik 2020년 2월 6일
First write the contents of your loop. What is the code you want to run for a single iteration? Only then should you start with putting a loop around that.
As for your last question: try to think what you are saying with that line. You are telling Matlab to create a vector (c+1) and run the code inside the loop for each element, using c as the variable to store the elements in. While that is valid code, it is probably not what you mean.
Have you considered doing a tutorial to get up to speed with the basic Matlab syntax?

댓글을 달려면 로그인하십시오.

채택된 답변

shobhit pipil
shobhit pipil 2020년 2월 8일
rch = rch_1960_NY6_1975;
flow_outF=zeros(3652,166);
x=rch;
flow=x(:,8);
c=0;
for i=1:166 %c=c+1
for c=c+1 %c<166
ind1 = rch(:,2) == c;
flow_out2= flow(ind1);
%dataToAppend = flow_out2+i;
end
% xlswrite('out.xlsx', flow_out2','A1:FJ2191')
%flow_out3 = cat(2,flow_out2);
% flow_out2 = [flow_out2 dataToAppend];
%flow_out2 = horzcat(flow_out2, dataToAppend);
flow_outF(:,c) = flow_out2;
if c==166
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by