@folder and +folder

The +folder piece is a MATLAB package folder. If you place Tata.m in a location like +folder/Tata.m, it will be known to MATLAB as the class folder.Tata. If you place it in a folder like someOtherFolder/Tata.m, or someOtherFolder/@Tata/Tata.m, it will be known to MATLAB as Tata. It can be useful to place a classdef file … Read more

Add custom legend without any relation to the graph

This is how I have solved this problem in the past: figure t=linspace(0,10,100); plot(t,sin(t)); hold on; h = zeros(3, 1); h(1) = plot(NaN,NaN,’or’); h(2) = plot(NaN,NaN,’ob’); h(3) = plot(NaN,NaN,’ok’); legend(h, ‘red’,’blue’,’black’); This will plot the additional points, but because the coordinates are at NaN they will not be visible on the plot itself: EDIT 26/10/2016: … Read more

Create a 3D matrix

Create a 3D matrix A = zeros(20, 10, 3); %# Creates a 20x10x3 matrix Add a 3rd dimension to a matrix B = zeros(4,4); C = zeros(size(B,1), size(B,2), 4); %# New matrix with B’s size, and 3rd dimension of size 4 C(:,:,1) = B; %# Copy the content of B into C’s first set of … Read more