Skip to content

Instantly share code, notes, and snippets.

@prerakmody
Last active November 10, 2020 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prerakmody/13e39571c57f48e57fa81d03b1a557c7 to your computer and use it in GitHub Desktop.
Save prerakmody/13e39571c57f48e57fa81d03b1a557c7 to your computer and use it in GitHub Desktop.
MATLAB Hacks
\newcommand*\xbar[1]{%
\hbox{%
\vbox{%
\hrule height 0.5pt % The actual bar
\kern0.5ex% % Distance between bar and symbol
\hbox{%
\kern-0.1em% % Shortening on the left side
\ensuremath{#1}%
\kern-0.1em% % Shortening on the right side
}%
}%
}%
}
bags = cell(N,1);
bags{i} = [];
cell2mat(bags{1})
filename = sprintf('data/TeddyBearPNG/obj%02d_016.png.haraff.sift', 1);
filename = ['data/TeddyBearPNG/obj' num2str(i, '%02d') '_016.png.haraff.sift'];
% Binarize indices
tmp = [1 3 10];
a = [];
for i=1:max(tmp), if (ismember(i, tmp) == 1) a = [a 1];, else a =[a 0];, end, end
%% Works
filename = matlab.desktop.editor.getActiveFilename;
cd (fileparts(matlab.desktop.editor.getActiveFilename))
addpath(genpath(fileparts(fileparts(matlab.desktop.editor.getActiveFilename))))
%% Does not work
cd (fileparts(which('main_q1')));
%% Startup
cd '~/Documents/MATLAB/startup.m' %[Ubuntu]
addpath("D:\<folder1>\<folder2>\<folder3>\images") // On the Home tab, in the Environment section, click Set Path and "Add with Subfolders"
which "filename.jpg" // to check if file in in path
figure;
p1 = subplot(1,2,1);
imshow(f_now); hold on;
scatter(unow_inliers, vnow_inliers);
title('Inliers');
p2 = subplot(1,2,2); hold on;
imshow(f_now);
scatter(unow_outliers, vnow_outliers);
title('Outliers');
pos1 = get(p1, 'Position');
pos2 = get(p2, 'Position');
disp(pos1);
disp(pos2);
pos2(1) = pos1(1) + pos1(3) + 0.1;
set(p2, 'Position', pos2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment