GithubHelp home page GithubHelp logo

matlab-tools's Introduction

MATLAB Tools

Miscellaneous tools for MATLAB projects; some to deal with objects and graphic handles in a safer way, others to accomplish complex behaviors missing in MATLAB.

Prerequisites

Code was last built and tested with

  • MATLAB R2018a

Installation

  • Install MATLAB
    • Download library from repository and place the MATLAB folder under Documents folder.
    • Create/modify Documents/MATLAB/startup.m and put addpath('Tools');

Usage examples

Example - Callbacks

% Invoke a function/method with arbitrary number of parameters.
Callbacks.invoke({@fprintf, '%s %s\n', 'Hello', 'world'});

% Invoke methods from (potentially disposed) objects.
t = timer('TimerFcn', @(~, ~)disp('Tic'));
Callbacks.invoke(t, 'start');
delete(t);
Callbacks.invoke(t, 'start');

Example - Delayed execution with Scheduler

% Print Hello after 1 second.
obj = Scheduler();
obj.delay({@disp, 'Hello'}, 1);

Example - Repeated execution with Scheduler

ticker = tic;
obj = Scheduler();
% Print elapsed time every second.
handle = obj.repeat(@()fprintf('Elapsed: %.0fs\n', toc(ticker)), 1);
% Stop process after 5 seconds.
obj.delay({@delete, handle}, 5);

Example - Container

% Create an object and change its dynamic properties.
container = Container('field1', 1, 'field2', 1:5);
container.set('greeting', 'Hello');
disp(container.field1);
disp(container.field2);
disp(container.greeting);

% Receive a container with arbitrary data from a MATLAB's event
% Create TestClass.m:
classdef TestClass < handle
	events
		Called;
	end

	methods (Access = private)
		function call(obj)
			obj.notify('Called', Container('Greeting', 'Hello', 'Field2', 2, 'Field3', 1:5));
		end
	end

	methods (Static)
		function test()
			testObject = TestClass();
			addlistener(testObject, 'Called', @(source, event)disp(event.Greeting));
			testObject.call();
		end
	end
end

% Then execute:
TestClass.test();

API Reference

While these libraries acquire a better shape, look at the documentation from within MATLAB: Type help followed by the name of any class (those files copied to Documents/MATLAB). Most classes list methods and properties with links that expand their description. For example type help Compression.

Version History

0.1.0

  • Initial Release: Library and example code

License

© 2018 Leonardo Molina

This project is licensed under the GNU GPLv3 License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.