How to save multiple outputs of a function with changing inputs
Show older comments
G'day, I am fairly new to MATLAB and I am trying to run a filter function for two separate inputs but saving the output data from each one so that I can plot them on the same graph. I know I can just write the function again with a different input and a different output variable name but I want it so that if I had more than two I wouldn't have to write it out a whole bunch of times. The changing input is N1 = [6,3] and I would like to save P6 and Hertz6. Any help would be greatly appreciated, Thanks.
The code I have written so far:
Rp = 0.5;
Rs = 20;
fs2 = 10000;
fc2 = [500,1000];
Ts2 = 1/fs2;
fn2 = fc2/(fs2/2);
for N1 = [6,3]
[Y6,X6] = ellip(N1,Rp,Rs,fn2,'stop');
[P6,W6] = freqz(Y6,X6,100);
Hertz6 = W6/(2*pi*Ts2);
end
figure(3);
plot(Hertz6,abs(P6));
title('Band-Stop Filter (Remove frequency from 500Hz to 1kHz)');
axis([0 4000 0 4.5]);
hold on
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!