//Creates a 1x1 Matrix called "FC"
Matrix FCMatrix = new Matrix(2500.0, "FC");
//Load the previous matrix named "FC" to Octave
jopas.Load(FCMatrix);
//Creates a 1x1 Matrix called "FR", you can do it like the previous one.
jopas.Load(5000.0, "FR");
String R = "1";
String A = "40";
//Executes the Octave commands using local variables
jopas.Execute("[N,W]=cheb1ord(FC/10000,FR/10000," + R + "," +A+ ")");
jopas.Execute("[B,A]=cheby1(N," + R + ",W)");
jopas.Execute("[H,F]=freqz(B,A,512,20000)");
jopas.Execute("modulodB=20*log10(abs(H))");
jopas.Execute("fase=unwrap(angle(H))");
jopas.Execute("Wc=W*10000");
/**
*XYPlots of "F" and "modulodB", the plot title is "Módulo", the
* X label is "Frecuencia (Hz)" and Y label is "Módulo (dB)".
*/
this.jopasLabel2.paintLabel("F", "modulodB", "Módulo","Frecuencia (Hz)", "Módulo (dB)");
//The same with "F" and "fase" variables
this.jopasLabel1.paintLabel("F", "fase", "Fase", "Frecuencia (Hz)", "Fase (rad)");
/**
* Shows the value of Octave's "N" variable in the label.
* jopas.Save always returns Matrix variable type.
* In this case the dimensions of Matrix is well known, is a 1x1 matrix
* So we access straight to (0,0) position of the Matrix
*/
this.jTextField6.setText(Double.toString(jopas.Save("N").getRealAt(0,0)));
this.jTextField5.setText(Double.toString(jopas.Save("Wc").getRealAt(0,0))); |