This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/programming/code/vectorsize.m

15 lines
593 B
Matlab

a = (11:20); % a vector with 10 Elements
fprintf('length of a: %i\n', length(a))
size_of_a = size(a); % get the size and store it in a new variable
% size_of_a is a vector itself
fprintf('number of dimensions (rank) of size_of_a: %i\n', length(size_of_a))
% get the value of the second element of size_of_a
fprintf('number of entries in the 2nd dimesion of a: %i\n', size_of_a(2))
%% Uebersichtliche Alternative?
s = size(a); % Speicher den Rueckgabewert von size() in einer Variablen
s(2) % Inhalt der zweiten Zahl, d.h. Laenge der 2. Dimension
size(a,2) % Kurze Alternative