Last active
November 10, 2020 09:40
-
-
Save prerakmody/13e39571c57f48e57fa81d03b1a557c7 to your computer and use it in GitHub Desktop.
MATLAB Hacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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 | |
}% | |
}% | |
}% | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bags = cell(N,1); | |
bags{i} = []; | |
cell2mat(bags{1}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = sprintf('data/TeddyBearPNG/obj%02d_016.png.haraff.sift', 1); | |
filename = ['data/TeddyBearPNG/obj' num2str(i, '%02d') '_016.png.haraff.sift']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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