【发布时间】:2021-09-05 23:14:59
【问题描述】:
我正在尝试在 matlab 中创建一个子图,但是此代码似乎无法使用。你对如何让它工作有什么建议吗? 我是一个编码新手,所以如果它不应该在这里,任何关于在哪里搜索这样的东西的帮助或建议将不胜感激。
Uinput=inputdlg({'width:',...
'thickness:',...
'length:',...
'density:',...
'natural frequency 1:',...
'natural frequency 2:',...
'natural frequency 3:',...
'natural frequency 4:',...
'damping ratio:'},...
'input',1,{'','','','','','','','',''});
w=eval(Uinput{1});
t=eval(Uinput{2});
L=eval(Uinput{3});
rho=eval(Uinput{4});
f1=eval(Uinput{5});
f2=eval(Uinput{6});
f3=eval(Uinput{7});
f4=eval(Uinput{8});
zn=eval(Uinput{9});
mnum=eval(Uinput{6});
%%
%COMMENT FROM HERE TO END
fn=[2.3481 14.7152 41.2033 80.7406]; % natural frequencies taken from task 1
kn=((2*pi.*fn).^2)*(L*w*t*rho); % equation to calculate the
zn1=0.01;
zn=[zn1 zn1 zn1 zn1];
phif=[0.011 0.063 0.159 0.294]; %force potential amplitudes and the applied position %mode shapes for the forcing location %nodes and antinode locations %YOU NEED TO CHANGE THESE. mode shapes for the forcing location for each mode
%50mm, 302mm, 600mm
phir=[0.3464 0.7112 -0.0083 -0.7455]; % response potential %modeshapes for the response locations %YOU NEED TO CHANGE THESE. mode shapes for the response location for each mode
f=linspace(0,100,5000);
for n = 1:length(fn),
r = f/fn(n);
hi(:,n) = phif(n)*phir(n)/kn(n)./(1-r.^2+j*2*zn(n)*r);
phin=hi(:,n)/(max(abs(hi(:,n)));
subplot(2,2,n);
plot(x,phin, '-o')
grid on
xlabel('position')
ylabel('normalised shape')
title(['Mode ' num2str(mnum) ', ' num2str(fn) ' Hz'])
end
h=abs(sum(hi,2));
loglog(f,h)
ylabel('H')
xlabel('frequency (Hz)')
【问题讨论】: