📄 matrices.m
字号:
%%% Some examples of basic array and matrix manipulations%% Cleanup the environmentclear; % clear the workspace clc; % clean the screen%% To create a vectorv = [1.0 2 3.0 4.0]fprintf('press enter to continue \n');pause%% To create a a 2x4 matrixA = [4.0 5.0 7.0 8.0; 9.0 10.0 11.0 12.0]fprintf('press enter to continue \n');pause%% To create a main diagonal matrixD = diag(v)fprintf('press enter to continue \n');pause%%4x4 identity matrixeye(4)fprintf('press enter to continue \n');pause%% Combine the blocks D and the 4x4 identity into an 8x4 matrix%% notice the answer is left in the special variable ans[D; eye(4)]fprintf('press enter to continue \n');pause%% a 3x3 matrix of all zeros (done 2 different ways)Z = zeros(3)Z = zeros(3,3)fprintf('press enter to continue \n');pause%% a matrix of all onesO = ones(2,3)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -