필터 지우기
필터 지우기

How to avoid data overwrite problem in looping

조회 수: 2 (최근 30일)
addy fang
addy fang 2020년 7월 21일
편집: addy fang 2020년 7월 21일
I have some data overwrite problem in looping
%%%%%%%read data%%%%%%%%%%%%%%%
origindata=importdata('rawdata.txt');
f=origindata(:,1);
a=origindata(:,2);
b=origindata(:,3);
c=origindata(:,4);
d=origindata(:,5);
fstep=0.17;
y=0;
for t=(0.1:0.1:20)
e=a-j*b;
u=c-j*d;
rl=u.*e.*f*t/3;
%%%save results in y1, for each t, it save three columns 3*y-2, 3*y-1 and 3*y%%%
y=y+1;
y1(:,3*y-2)=f;
y1(:,3*y-1)=rl;
y1(:,3*y)=t;
%%%select data from three columns 3*y-2, 3*y-1 and 3*y and save in x1, only select those with rl value less than 0%%%
x1=y1(y1(:,3*y-1)<0, :); hold on;
%%%count the number of row in column 3*y-1%%%
n=size(x1,3*y-1);
totalwidth = fstep*(n+4);
%%%write the data in columns 3*y-2, 3*y-1 and 3*y%%%
x1(n+4, 3*y-2:3*y)=[totalwidth 0 t];
hold on;
end;
xlswrite('y1',y1);
xlswrite('x1',x1);
Problems: in x1, the last three column overwrite all previous columns.
Can anyone help me out? Thank you.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by