To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
Hi, im new to matlab. Im having trouble with the following code. I have to do a plot of "gamma" in the end, but I get an error message saying that the matrix dimension must agree.
%% %universal constants c = 345; rho = 407 / c; L = 1; %frequency here N = 5; % number of sections dx = L / N; T = (L / c) / N; Fs = 1 / T; % sample rate required npoints = 2^12; f = linspace(0, Fs, npoints); % frequency vector %equations here w = 2*pi*f; s = i*w; rc = 0.00375; rrad = c / w; Ac = pi*(rc^2); Arad = 2*pi*(rrad^2); z0 = rho*c/Ac; Yrad = (Arad/(s*rc*rho))+(Arad/(rho*c)); Zrad = 1 / Yrad; gamma = (Zrad-z0)/(Zrad+z0) plot(abs(gamma)) end
Have a great day!
No products are associated with this question.
Do you want rrad to be a scalar or a vector of the same size as c and w? For the later case, you need the elementwies division:
rrad = c ./ w;
The same concerns Arad = 2*pi*(rrad^2) also, where you'd need rrad .^ 2, and the same for the following vector operations with .* instead of * .