MATLAB練習(xí)例子十四(模擬計(jì)算2)
返回
》 test30.m
??? Attempt to reference field of non-structure.
ソリューション:
ご使用のコンピュータ自體のネットワーク設(shè)定で "localhost" の名前解決ができていない場合にこのような現(xiàn)象になります。まず、使用中のコンピュータ自體の名前解決の確認(rèn)を行うために MATLAB 上で以下のコマンドを?qū)g行します。
java.net.InetAddress.getLocalHost
または、コンピュータ自體に "ping" を送信し、応答があるかを確認(rèn)します。
エラーとなる場合は、 /etc/hosts にホスト名を追加するなどの方法で名前解決します。
Don't put the .m after the test30.
It's thinking that you have a structure called test30 and that you're
trying to display the value of the "m" member of that structure in the
command window. Simply type m3 and hit enter.
--------------------------------------------------------------------
% fft001.m
fid = fopen('fftinput001.csv','r');
header1 = fgetl(fid);
%header1
header2 = fgetl(fid);
%header2
header3 = fgetl(fid);
%header3
header4 = fgetl(fid);
%header4
header = fgetl(fid);
header
D1 = fread(fid);
fclose(fid);
whos D1
---------------------------------------------
》 fft001
header =
TIME,ch1,ch2,,
Name Size Bytes Class
D1 326337x1 2610696 double array
Grand total is 326337 elements using 2610696 bytes
%fft2.m
t = 0:1/100:10-1/100;
x = sin(2*pi*50*t);
y = fft(x);
m = abs(y);
p = unwrap(angle(y));
f = (0:length(y)-1)'*100/length(y);
subplot(2,1,1), plot(f,m),
ylabel('Abs. Magnitude'), grid on
subplot(2,1,2), plot(f,p*180/pi)
ylabel('Phase [Degrees]'), grid on
xlabel('Frequency [Hertz]')
f=45Hz

f=50Hz
傅立葉變換
%fft1.m
t = 0:1/100:10-1/100;
x = sin(2*pi*15*t) + sin(2*pi*40*t);
y = fft(x);
m = abs(y);
p = unwrap(angle(y));
f = (0:length(y)-1)'*100/length(y);
subplot(2,1,1), plot(f,m),
ylabel('Abs. Magnitude'), grid on
subplot(2,1,2), plot(f,p*180/pi)
ylabel('Phase [Degrees]'), grid on
xlabel('Frequency [Hertz]')
龍格庫塔法
% sim2_2.m
A = [0 1; -1 -1];
B = [0;1];
u = 1;
dt = 0.05;
tf = 20;
x = [0 0]';
xx = [];
i = 0;
for t = 0:dt:tf
i = i + 1;
xx(:,i) = x;
xt = x;
for j=1:4
f = A*x + B*u;
d(:,j) = f*dt;
x = xt + d(:,j)*0.5;
if j==3
x = xt + d(:,j);
end
end
x = xt + (d(:,1) + d(:,2)*2 + d(:,3)*2 + d(:,4))/6;
end
t = 0:dt:tf;
figure(1)
plot(t,xx)
grid on
歐拉法
% sim2_1.m
A = [0 1; -1 -1];
B = [0;1];
u = 1;
dt = 0.05;
tf = 20;
x = [0;0];
xx = [];
i = 0;
for t = 0:dt:tf
i = i + 1;
xx(:,i) = x;
dx = A*x + B*u;
x = x + dx*dt;
end
t = 0:dt:tf;
plot(t,xx)
grid on
返回
甘孜县|
华蓥市|
安龙县|
元江|
汉源县|
准格尔旗|
南陵县|
堆龙德庆县|
邹城市|
衢州市|
儋州市|
江永县|
永善县|
高台县|
大邑县|
凤翔县|
丽江市|
武穴市|
安庆市|
探索|
日土县|
保靖县|
寿宁县|
邮箱|
民乐县|
乳山市|
长武县|
澳门|
昭觉县|
信丰县|
库车县|
葫芦岛市|
温泉县|
鄂伦春自治旗|
教育|
曲阜市|
惠州市|
眉山市|
京山县|
教育|
清新县|