* Example of starting octave in WSL2, and loading in two columns of data from a text file And then plotting them with three different graphics environments (gnuplot is prob the most robust) > octave --no-gui % %%%%%%%%%%%%%%%%%%%%%%%% graphics_toolkit gnuplot fp = fopen('datafile.txt', 'r'); greg = fscanf(fp, '%f %f', [2 Inf]); fclose(fp); tvec = greg(1, 1:end); yvec = greg(2, 1:end); plot(tvec, yvec) % %%%%%%%%%%%%%%%%%%%%%%%% % %%%%%%%%%%%%%%%%%%%%%%%% graphics_toolkit qt fp = fopen('datafile.txt', 'r'); greg = fscanf(fp, '%f %f', [2 Inf]); fclose(fp); tvec = greg(1, 1:end); yvec = greg(2, 1:end); plot(tvec, yvec) % %%%%%%%%%%%%%%%%%%%%%%%% % %%%%%%%%%%%%%%%%%%%%%%%% graphics_toolkit fltk fp = fopen('datafile.txt', 'r'); greg = fscanf(fp, '%f %f', [2 Inf]); fclose(fp); tvec = greg(1, 1:end); yvec = greg(2, 1:end); plot(tvec, yvec) % %%%%%%%%%%%%%%%%%%%%%%%% * Interactive gnuplot commands (you can get these commands by starting gnuplot from bash - then type "show bind") 2x print coordinates to clipboard using `clipboardformat` (see keys '3', '4') annotate the graph using `mouseformat` (see keys '1', '2') or draw labels if `set mouse labels is on` remove label close to pointer if `set mouse labels` is on mark zoom region (only for 2d-plots and maps). change view (rotation). Use to rotate the axes only. change view (scaling). Use to scale the axes only. vertical motion -- change xyplane Space raise gnuplot console window q * close this plot window a `builtin-autoscale` (set autoscale keepfix; replot) b `builtin-toggle-border` e `builtin-replot` g `builtin-toggle-grid` h `builtin-help` l `builtin-toggle-log` y logscale for plots, z and cb for splots L `builtin-nearest-log` toggle logscale of axis nearest cursor m `builtin-toggle-mouse` r `builtin-toggle-ruler` 1 `builtin-decrement-mousemode` 2 `builtin-increment-mousemode` 3 `builtin-decrement-clipboardmode` 4 `builtin-increment-clipboardmode` 5 `builtin-toggle-polardistance` 6 `builtin-toggle-verbose` 7 `builtin-toggle-ratio` n `builtin-zoom-next` go to next zoom in the zoom stack p `builtin-zoom-previous` go to previous zoom in the zoom stack u `builtin-unzoom` Right `builtin-rotate-right` only for splots; increases amount Up `builtin-rotate-up` only for splots; increases amount Left `builtin-rotate-left` only for splots; increases amount Down `builtin-rotate-down` only for splots; increases amount Escape `builtin-cancel-zoom` cancel zoom region * indicates this key is active from all plot windows * Plot simple graph graphics_toolkit gnuplot xvec = (0:400)*6*pi/400; yvec = sin(xvec); plot(xvec, yvec); * Very important available_graphics_toolkits graphics_toolkit gnuplot fs = 2e6; wc = pi / 4 * fs; df = fs / 2 / 1000; f = (0:1000) * df; s = i * 2*pi*f; T = 1/fs; z = exp(i*2*pi*f*T); Ha = 1./(1+s./wc).^2; plot(f, Ha) figure --> bring up a figure window ' --> transpose operator ; --> end of a row in a matrix start:end or start:step:end >> a = [1:1:10] a = 1 2 3 4 5 6 7 8 9 10 *********************************** octave --gui https://www.mathworks.com/help/matlab/getting-started-with-matlab.html * complex numbers --> i or j * ; --> suppress printing answer * a = [1 2 3; 4 5 6; 7 8 9] * format long format short * b = zeros(5, 1) * A(4, 2) --> row=4 col=2 rows begin at 1 cols begin at 1 strangely, you can refer to this as A(8) The data in an array is stored in terms of columns serially * A(1:3, 2) --> column vector taken from col=2 * A = 0 A(10, 6) = 1.5 (this add 9 rows and 5 cols) * A(3, :) B = 0:10:100 --> [0 10 20 30 40 50 60 70 80 90 100] B = 0:10 --> [0 1 2 3 4 5 6 7 8 9 10] * D = rand(3, 5, 2) D(:,:,1) D(:,:,2) * save myfile.mat * load myfile.mat * (begin example myfile.mat) # Created by Greg Warwar # name: greg # type: matrix # ndims: 2 3 2 1 2 3 4 5 6 # name: shan # type: matrix # rows: 3 # columns: 2 1 4 2 5 3 6 * (end example myfile.mat)