vecSpace
Versión 1.0.0 (2,73 KB) por
Peter Krammer
Function for splitting given interval into multiple subintervals, with several strategies. It allows linear, log, manlog, geom, also vectors
function vecSpace replacing multiple functions : linspace(), logspace() and geomspace (inspired from python).
Also, it allows using vectors as inputs ( standard matlab functions linspace and logspace support scalars only).
%%function [points] = vecSpace(x1, x2, n, spaceType)
% This function works as alternative of functions linspace(), logspace() or (geomspace() from python).
% It is easier to remember only 1 function name. Function using original matlab functions, but also supports
% working with x1 and x2 as column vectors.
%
% x1 - is starting column vector of real numbers
% x2 - is ending column vector of real numbers
% n - is number of values - integer (there are 2 outer values (x1 and x2), and n-2 other generated values)
% spaceType - describe type of space
% supported values are:
% "lin" - linear space
% "geom" - geometric space
% "log" - logaritmic space/splitting (from 1e^x1 to 1e^x2)
% "manlog" - logaritmic space/splitting calculated manually (from x1 to x2)
% (it gives different solutions than original logspace() function in Matlab R2020b)
% points - output of function, which separate space <x1,x2> into n-1 intervals
%
% example 1: vecSpace([1;10], [256; 256],9, 'geom')
% 1.0000 2.0000 4.0000 8.0000 16.0000 32.0000 64.0000 128.0000 256.0000
% 10.0000 14.9979 22.4937 33.7357 50.5964 75.8840 113.8099 170.6907 256.0000
%
% example 2: vecSpace([-100;0], [10; 50], 10) % default = linear splitting
% -100.0000 -87.7778 -75.5556 -63.3333 -51.1111 -38.8889 -26.6667 -14.4444 -2.2222 10.0000
% 0 5.5556 11.1111 16.6667 22.2222 27.7778 33.3333 38.8889 44.4444 50.0000
%
% example 3 (from 1e1 to 1e3) : vecSpace(1, 3, 6, 'log')
% 1.0e+03 *
% 0.0100 0.0251 0.0631 0.1585 0.3981 1.0000
%
% example 4: vecSpace(1, 3, 6, 'manlog')
% 1.0000 1.2457 1.5518 1.9332 2.4082 3.0000
Citar como
Peter Krammer (2024). vecSpace (https://www.mathworks.com/matlabcentral/fileexchange/110090-vecspace), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Se creó con
R2020b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS LinuxEtiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0 |