【Matlab】matlab常用函数(自定义)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaoxiao133/article/details/86081052

Matlab强大的函数库涉及各个领域

matlab各个领域的函数库:https://ww2.mathworks.cn/matlabcentral/fileexchange/

发现向量arrayA中最小的Num个数

function [ minFlags ] = findMinFlag( arrayA,num )
%FINDMINFLAG Summary of this function goes here
%   Detailed explanation goes here
minFlags = [];
for i = 1:num
    [~,tempFlag] = min(arrayA);
    minFlags = [minFlags;tempFlag];
    arrayA(tempFlag) = inf;
end
minFlags = sort(minFlags,'ascend');
end


GNSS坐标转换成NEU方向以及时间转换代码链接

https://github.com/XiaoGongWei/Ubuntu16.04-llaptop-Code/blob/master/store_data/CoordTransfer.zip
XYZ_NEU.m代码调用方式如下XYZ_NEU。
ppp_pos是求解坐标,true_pos是真实坐标。

function plot_ppp_pos( ppp_pos, true_pos )
%PLOT_PPP_POS Summary of this function goes here
%   Detailed explanation goes here
data_len = length(ppp_pos);
diff_pos_NEU = zeros(data_len, 3);
for i = 1:data_len
    diff_pos_NEU(i,:) = XYZ_NEU(ppp_pos(i, :), ppp_pos(i, :) - true_pos);
end

h2 = figure;
hold on
plot(diff_pos_NEU,'.');
legend('dN','dE','dU')

end

Matlab读取txt文件

function [ Out_mat ] = readmyTxt( txtFilename, beginFlag, selectFlag )
%READMYTXT Summary of this function goes here
%   Detailed explanation goes here
Out_mat = [];

fid = fopen(txtFilename, 'r');
if fid == -1
    error('open file bad.');
    return ;
end

while ~feof(fid)
    strline_t = fgetl(fid);
    strline = strline_t(beginFlag:end);
    strline = strrep(strline, ':', ' ');
    vct_line = str2num(strline);
    myvct = vct_line(selectFlag);
    Out_mat = [Out_mat; myvct];   
end
fclose(fid);

end


集合剔除元素

setdiff([1:11],[2,4,5])
ans =     1     3     6     7     8     9    10    11

猜你喜欢

转载自blog.csdn.net/xiaoxiao133/article/details/86081052
今日推荐