matlab-performance-optimizer

Solid

Optimize MATLAB code for better performance through vectorization, memory management, and profiling. Use when user requests optimization, mentions slow code, performance issues, speed improvements, or asks to make code faster or more efficient.

API & Backend 156 stars 31 forks Updated today NOASSERTION

Install

View on GitHub

Quality Score: 80/100

Stars 20%
73
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# MATLAB Performance Optimizer Optimize MATLAB code performance with vectorization, memory management, and profiling tools. ## When to Use This Skill - Optimizing slow or inefficient MATLAB code - Converting loops to vectorized operations - Reducing memory usage - Improving algorithm performance - When user mentions: slow, performance, optimize, speed up, efficient, memory - Profiling code to find bottlenecks - Parallelizing computations ## Core Optimization Principles ### 1. Vectorization (Most Important) **Replace loops with vectorized operations whenever possible.** **SLOW - Using loops:** ```matlab % Slow approach n = 1000000; result = zeros(n, 1); for i = 1:n result(i) = sin(i) * cos(i); end ``` **FAST - Vectorized:** ```matlab % Fast approach n = 1000000; i = (1:n).'; result = sin(i) .* cos(i); ``` ### 2. Preallocate Arrays **Always preallocate arrays before loops.** **SLOW - Growing arrays:** ```matlab % Very slow - array grows each iteration result = []; for i = 1:10000 result(end+1) = i^2; end ``` **FAST - Preallocated:** ```matlab % Fast - preallocated array n = 10000; result = zeros(n, 1); for i = 1:n result(i) = i^2; end ``` ### 3. Use Built-in Functions **MATLAB built-in functions are highly optimized.** **SLOW - Manual implementation:** ```matlab % Slow sum_val = 0; for i = 1:length(x) sum_val = sum_val + x(i); end ``` **FAST - Built-in function:** ```matlab % Fast sum_val = sum(x); ``` ## Vectorization Techniques ### Element-wi...

Details

Author
matlab
Repository
matlab/agent-skills-playground
Created
9 months ago
Last Updated
today
Language
HTML
License
NOASSERTION

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category