Script issue between two different versions
显示 更早的评论
Hi, I was wondering if you may be able to tell me if there is a dramatic difference between the 2010b version and the 2011a version. I wrote a simple script in the 201b version, where is works fine, but when I try and run it in the 2011a version I get a error message half way through.
[SCd indented code]
??? Error using ==> mldivide
Matrix dimensions must agree.
Error in ==> EET3300_HW1 at 17
H = 1/(((WW).^4+2.6131*(WW).^3+3.414*(WW).^2+2.6131*(WW)+1));
The script is as follows:
% 2-26-12
% Jeff Johnson
% EET3300
clc
clear all
%Enters in variables into a matrix
freq_cut = input('Enter the frequency cutoff:');
num = input('Enter in the number of frequencies:');
for k = 1:num
f(k) = input('Enter in a frequency:');
end
syms W Wf
WW = (j*f)/(2*pi*freq_cut);
H = 1/(((WW).^4+2.6131*(WW).^3+3.414*(WW).^2+2.6131*(WW)+1));
for cnt = 1:num
Wf = (cnt-1)*freq_cut*2*pi;
HH = subs(H,W,Wf);
HA = abs(HH);
end
HH
HA
ANy help you may be able to provide would be greatly appreciated.
Thank you,
Jeff
回答(1 个)
Sean de Wolski
2012-3-8
It's not an issue between version incompatibility but rather dependent on your input(). It would not fail if everything is a scalar, but will if you input a vector or matrix. Thus is num is one, it'll work but if it's two or more - BOOM!
It looks like it should be:
H=1./(((etc...
And:
doc vectorize
to have this automagically done for you.
vectorize('H = 1/(((WW).^4+2.6131*(WW).^3+3.414*(WW).^2+2.6131*(WW)+1));')
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!