フィルターのクリア

help needed on Bandwidth over certain thredshold in a loop

2 ビュー (過去 30 日間)
addy fang
addy fang 2020 年 7 月 14 日
I am new to Matlab and hope someone can help me out. I try to get the bandwidth at certain reading of a peak, and write the following code. But run into a few problems. The codes are follows.
%%%read in data%%%%
origindata=importdata('rawdata.txt');
f=origindata(:,1);
a=origindata(:,2);
b=origindata(:,3);
c=origindata(:,4);
d=origindata(:,5);
%%% loop t for calculation %%%
y=0;
for t=(0.1:0.1:20)
e=a-j*b;
u=c-j*d;
rl=(u./e).*f*t;
%%%%save results%%%
y=y+1;
y1(:,3*y-2)=f;
y1(:,3*y-1)=rl;
y1(:,3*y)=t;
%%%find minimum and bandwidth%%%%
RLmax=min(rl);
w1=f(f(abs(rl+10)<0.1)<f(rl==RLmax));
w2=f(f(abs(rl+10)<0.1)>f(rl==RLmax));
width=w2-w1;
%%%%save results at each t%%%
z1(y,1)=t;
z1(y,2)=f(rl==RLmax);
z1(y,3)=RLmax;
z1(y,4)=w1;
z1(y,5)=w2;
z1(y,6)=width;
thickness=z1(:,1);
frequency=z1(:,2);
peak=z1(:,3);
frequency1=z1(:,4);
frequency2=z1(:,5);
bandwidth=z1(:,6);
hold on;
end;
%%%%find minimum and bandwidth over all the t and save final results%%%%
p = min(z1(:,3));
th = thickness(z1(:,3)==p);
freq = frequency(z1(:,3)==p);
freq1 = frequency1(z1(:,3)==p);
freq2 = frequency2(z1(:,3)==p);
bandwid = bandwidth(z1(:,3)==p);
z1(y+3,1)=th;
z1(y+3,2)=freq;
z1(y+3,3)=p;
z1(y+3,4)=freq1;
z1(y+3,5)=freq2;
z1(y+3,6)=bandwid;
%%%%save results in files%%%
xlswrite('y1',y1);
xlswrite('z1',z1);
Error message after run:
"Unable to perform assignment because the size of the left side is 1-by-1 and the size of the
right side is 0-by-1."
It seemed the following codes caused problem, as I removed them and related, it ran ok.
w1=f(f(abs(rl+10)<0.1)<f(rl==RLmax));
w2=f(f(abs(rl+10)<0.1)>f(rl==RLmax));
width=w2-w1;
But I need to extract those to extract bandwidth information. Can anyone help me out? Thank you.

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by