VGRID: utility to help vectorize code

버전 1.0.0.0 (2.31 KB) 작성자: Sky Sartorius
VGRID helps vectorize code to handle n-d variables as inputs for e.g. trapz.
다운로드 수: 202
업데이트 날짜: 2016/4/13

라이선스 보기

[siz,V,M,X1,X2,X3,...] = VGRID(v,x1,x2,x3,...) expands the inputs x1,x2,x3,... using meshgrid such that e.g. reshape(trapz(V,Xi),siz) is the same size as xi if xi is N-D. Use vgrid to help make your code more vectorized.

Input v is a vector. For each non-scalar xi, vgrid returns [Xi, M] = meshgrid(xi, v). Xi = xi for scalar xi.

Example: Numerically integrate the position of an object with various acceleration and starting velocity (without for loops).
time = 0:.1:3; % Seconds.
[v0,acceleration] = meshgrid(0:4,4:2:16); % Units: m/s and m/s^2.
[siz,timeVector,TimeGrid,V0,Acceleration] = VGRID(time,v0,acceleration);
velocity = V0 + Acceleration.*TimeGrid;
distance = trapz(timeVector,velocity);
distance = reshape(distance,siz);
surf(v0,acceleration,distance);

인용 양식

Sky Sartorius (2024). VGRID: utility to help vectorize code (https://www.mathworks.com/matlabcentral/fileexchange/56529-vgrid-utility-to-help-vectorize-code), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0