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
返回
紫云| 苏尼特右旗| 新宁县| 龙岩市| 冀州市| 阳春市| 和静县| 耒阳市| 宁海县| 资阳市| 淮安市| 西城区| 永川市| 巴里| 广西| 博湖县| 山西省| 海晏县| 宁河县| 长汀县| 成安县| 普宁市| 肥东县| 宁津县| 余庆县| 永康市| 永和县| 西乌| 会泽县| 修水县| 鹿泉市| 新宾| 盈江县| 牙克石市| 罗甸县| 沁水县| 葫芦岛市| 高台县| 邛崃市| 德保县| 米脂县|