3 errors in a script line - 11, 13, 28

조회 수: 2 (최근 30일)
pankaj khaire
pankaj khaire 2021년 8월 8일
댓글: Walter Roberson 2021년 8월 9일
'Shock Response Spectrum';
'CrLf';
ymax=[ ];
ff=[ ];
fmin=1;
fmax=1000;
n=90;
qv=(fmax/fmin)^(1/n);
T=1/get(input1,'freq');
Q=10;
for[i=0;1;1i<n;i=i+1];
{
fn=[fmin*qv^i];
ff=[ff,fn];
wn=2*pi*fn;
A=wn*T/2/Q;
B=wn*T*sqr(1-1/4/Q/Q);
b0=1-exp(-A)*sin(B)/B;
b1=2*exp(-A)*(sin(B)/B-cos(B));
b2=exp((-2)*A)-exp(-A)*sin(B)/B;
a1=(-2)*exp((-1)*A)*cos(B);
a2=exp((-2)*A);
BB=[b0,b1,b2];
AA=[-a1,-a2];
y=filter(input1,BB,AA);
yy=max(y);
ymax=[ymax,yy];
};
save(ff);
save(ymax);

답변 (1개)

DGM
DGM 2021년 8월 9일
T=1/get(input1,'freq');
input1 is a missing variable/object, so you'll have to figure that out. If this is is someone else's code, I have less information than you do about what it could possibly be.
for[i=0;1;1i<n;i=i+1];
{
% ...
};
I have no idea what language this is from, but it's not MATLAB. I am not familiar with any 4-argument for loop syntax, so I have no idea what the 1 means. You're using i as both an integer index and you're attempting to explicitly use it as a complex number. Both i and j are sqrt(-1). Unless you're using them as that, don't cause problems by overloading them for use as indices or something.
B=wn*T*sqr(1-1/4/Q/Q);
I'm assuming that's supposed to be sqrt()?
y=filter(input1,BB,AA);
Again, I'm assuming input1 is some variable you have already.
Without the missing variable, this is my best guess:
clc; clearvars
ymax=[ ];
ff=[ ];
fmin=1;
fmax=1000;
n=90;
qv=(fmax/fmin)^(1/n);
%T=1/get(input1,'freq');
T = 1/200; % fake number to make it run
Q=10;
for k = 0:n-1 % is this right?
fn=fmin*qv^k;
ff=[ff,fn];
wn=2*pi*fn;
A=wn*T/2/Q;
B=wn*T*sqrt(1-1/4/Q/Q);
b0=1-exp(-A)*sin(B)/B;
b1=2*exp(-A)*(sin(B)/B-cos(B));
b2=exp((-2)*A)-exp(-A)*sin(B)/B;
a1=(-2)*exp((-1)*A)*cos(B);
a2=exp((-2)*A);
BB=[b0,b1,b2];
AA=[-a1,-a2];
%y=filter(input1,BB,AA);
y=filter(BB,BB,AA); % just cram something in it so it runs
yy=max(y);
ymax=[ymax,yy];
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 8월 9일
I am wondering if
for[i=0;1;1i<n;i=i+1];
is some kind of combination of
for i=0:1:1
and a C / C++
for (i=0; i <n; i++)

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

카테고리

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

태그

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by