Commit e004daca by Aaron Erhardt

### Matlab lecture 26.4


Signed-off-by: Aaron Erhardt <aaron.erhardt@t-online.de>
parent 20d90fd2
 ... ... @@ -222,6 +222,7 @@ disp('Hello') fprintf(1, 'value: %d\n', 2)  # Datatypes ## Structs ... ... @@ -285,6 +286,7 @@ table{1, 2} % row 1, column 2, note brackets! table{:, 2} % column 2  # Save and load ## Workspace ... ... @@ -338,7 +340,9 @@ y = polyval(p, x); # Graphics ## Plot ## Plots ### Plot matlab x = 1:10; ... ... @@ -347,6 +351,43 @@ plot(y); % automatic x-axis plot(x, y); % custom x-axis  ### Stairs plot matlab stairs(x, y); % plot values as stairs  ### Discrete values matlab ffty = fft(y); % fast-fourier transform stem(x, abs(ffty)); % plot FFT  ### Logarithmic matlab loglog(x, y); % both axes are logarithmic  ### Semi-logarithmic matlab semilogx(x, y); % x-axes is logarithmic, y-axis is linear semilogy(x, y); % x-axes is linear, y-axis is logarithmic  ## Charts ### Bar matlab h = bar([1 2 4 8]); % create bar chart h.FaceColor = [0, 0.7 0]; % set properties  ## Plot options ### Hold (keep previous plots) matlab ... ... @@ -417,12 +458,68 @@ xlabel('\alpha'); % set x-label to α ylabel('y');  ### Axes matlab axis([XMIN XMAX YMIN YMAX]); % set scaling of both axes  ## Figures matlab fig = figure fig = figure; % note: properties are case sensitive! fig = gcf; % get handle to current figure  ### Typical object hierarchy mermaid graph Structure; Figure-->Legend; Figure-->Axes; Axes-->Lines;  ### Set color matlab fig.Color = 'w'; % white fig.Color = [1.0 0.5 0.0]; % RGB  ### Plot handles matlab h = plot(x, y); % get handle h.LineWidth = 1.3; % modify properties h.Marker = '.'; % set marker  ### Sub-plots matlab fig = figure; subplot(2, 3, 1); % 2x3 matrix of plots, select first plot plot(x, y); % first plot subplot(2, 3, 2); % 2x3 matrix of plots, select second plot loglog(x, y); % second plot subplot(2, 3, 4); % 2x3 matrix of plots, select fourth plot semilogx(x, y); % second row, first plot subplot(2, 3, 6); % 2x3 matrix of plots, select last plot semilogy(x, y); % second row, third plot  Get handle matlab handle = subplot(2, 3, 1); % select first plot handle.Children(1).LineWidth = 2; % get line from handle and change width  # Control structures ## for-loop ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!