Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

help with probably one of the simplest problem...

sylphid707sylphid707 Posts: 2Member
Hi guys, I'm very new to Matlab... I've been using mathematica but my professor insisted that I should start using matlab... This code is about plotting the magnitude of 'gamma'. The domain of the horizontal axis is frequency, and I want it such that I could modify the sampling rate easily.
When I run the code, I get an error saying that the matrix doesn't match...

%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);

And one more question, what is the code for defining the plot range of the Y-axis?

Have a great day guys =)
Sign In or Register to comment.