Contents

Matlab notes

tutorial

科学计算与MATLAB语言 刘卫国 中南大学

New Ways to Work in Simulink

function

1
2
B = A.'  
B = transpose(A)

contains 确定字符串中是否有

sortrows Sort rows of matrix or table

unique Unique values in array

Optimization Toolbox™ 教程
https://ww2.mathworks.cn/help/optim/ug/optimization-toolbox-tutorial.html
https://ww2.mathworks.cn/help/optim/ug/optim.problemdef.optimizationproblem.optimoptions.html

script

1
2
3
4
5
#matrix 
A = [1 2 3 4 ; 5 6 7 8; 1 2 9 10; 2 5 11 12]

#Determinate
a = det (A)

在cell中找指定元素

1
2
3
4
5
6
a_cell = {'ni', 'hao', 'hao'}
% 第一种方法
idx = find(ismember(a_cell, 'ni' ))

% 第二种方法
idx = find(strcmp(a_cell, 'ni' ))

输出

1
2
3
idx =

     2     3

import file

1
2
3
4
5
% T = readtable('./file.csv');

% T1 = importdata('./file.csv');

% T2 = load('./file.csv'); 

readtable textscan

b= xjxjx 49599 b(isstrprop(b,‘digit’)) regexp( b, ‘(?<=\w+)\d+’, ‘match’ )

regexp(eff(1),’\d+.?\d*’,‘match’)