Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matlab-snippets #128

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/matlab-snippets/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## MATLAB Snippets
A small package for [espanso](https://espanso.org/) with triggers for headers and code snippets I constantly use in [MATLAB](https://www.mathworks.com/products/matlab.html?s_tid=hp_products_matlab). Feel free to use and modify any of these as you see fit.

### Global Variables:
myName
Global variable for your name. Make sure to change to your name or username. Can be replaced in the headers with any pre-existing variables that have your name.

### Triggers:
:matHead
Generic header form with spaces to enter the file name, a summary and any collaborators.
:matFunc
Generic Function header with blanks to enter the function name, a summary and any collaborators.
:matPlot
Code snippet with basic commands used when making a plot. Saves figure to a variable that can be used to reopen, modify and print a plot.
:matPrnt
Code snippet for printing out MATLAB figures (.fig). Uses the name assigned to a variable as seen in :matPlot
:matData
Code snippet for loading multiple files from a folder into a structure.

Last Updated: 08/19/2024
6 changes: 6 additions & 0 deletions packages/matlab-snippets/0.1.0/_manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "matlab-snippets"
title: "MATLAB Snippets"
description: Headers and code snippets for use in MATLAB
version: 0.1.0
author: MistressOfUniverses
tags: ["v0.1.0". "matlab". "snippets". "espanso"]
67 changes: 67 additions & 0 deletions packages/matlab-snippets/0.1.0/matlab-snippets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Global Variables
global_vars:
- name: myName
type: echo
params:
echo: "Your Name Here"

matches:
# Headers
# Generic Header
- trigger: ":matHead"
form: |
%% [[fileName]] - Main
% [[Summary]]
%
% Author: {{myName}}
% Collaborators: [[Collaborators]]
% Last Modified: :date

% Start Code
clc; clear all; close all;
form_fields:
text:
multiline: true

# Function Header
- trigger: ":matFunc"
form: |
function [] = [[funcTitle]]()
%% [[Summary]]
%
% Author: {{myName}}
% Collaborators: [[Collaborators]]
% Last Modified: :date
% Inputs:
%
% Outputs:
%
% Methodology:

end;
form_fields:
text:
multiline: true

# MATLAB Specific Code
# Basic Plot Template
- trigger: ":matPlot"
replace: |
% figure()
figure(); hold on; grid on; grid minor
plot();
title(); xlabel(); ylabel()
hold off;

# Print Graphs
- trigger: ":matPrnt"
replace: "print( ,'-dpng','title.png')"

# Load in Data
- trigger: ":matData"
replace: |
files = dir('FolderName/');
for temp = 3:4
long_name = strcat(files(temp).folder,'/',files(temp).name);
raw_data.(files(temp).name) = readtable(long_name);
end
Loading