フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by