- 博客(73)
- 资源 (3)
- 收藏
- 关注
原创 快速提升图片外围的滤波效果
Image Processing Toolbox-Increase Filter Strength Radially Outward
2022-08-26 20:44:51
776
1
原创 实战4 - 汽车行驶工况构建
题目来源于2019年中国研究生数学建模竞赛D题——汽车行驶工况构建。在本次实战的数据分析过程中,涉及以下技术内容:(1)数据预处理技术(2)for循环的使用(3)暴力搜索方法
2022-06-22 23:24:24
2219
2
原创 实战2 - 疫情背景下的周边游需求图谱分析(问题一)
来源于2022泰迪杯C题——疫情背景下的周边游需求图谱分析。随着互联网和自媒体的繁荣,文本形式的在线旅游(Online Travel Agency,OTA)和游客的用户生成内容(User Generated Content,UGC)数据成为了解旅游市场现状的重要信息来源。OTA 和UGC 数据的内容较为分散和碎片化,要使用它们对某一特定旅游目的地进行研究时,迫切需要一种能够从文本中抽取相关的旅游要素,并挖掘要素之间的相关性和隐含的高层概念的可视化分析工具。为此本赛题提出本地旅游图谱这一概念,它在通用知识图谱
2022-06-06 21:47:41
826
原创 matlab如何按行查找重复值?
unique是去重函数,那查重函数是哪个?我没找到,所以自己用for循环编了个,能实现“查找重复项”的功能。function Data_out=chachong(data)data_unique=unique(data);find_rows=[];hang=size(data_unique,1);lie=size(data_unique,2);for i=1:hang b=data_unique(i,:); rr=(data==b); numf=find(sum(rr,2
2022-06-01 09:14:09
3724
原创 readtable函数导入.csv文件技巧
在使用readtable函数导入.csv文件时,默认是以逗号为分隔符来分隔各列,我发现如果某个单元格里含有逗号,则会在逗号位置断开,形成两列,这样导入完成后有各列错位的问题发生。我摸索了一种方法,就是把工具栏里“导入数据”工具自动生成的代码,进行适当修改,就能避免因单元格内部内容里有逗号导致各列错位问题。原理不清楚,重在好用,如果大家也遇到类似问题,可以参考。table_tem1=readtable('数据.csv','Delimiter',",");v_t = repmat("string",1,si
2022-06-01 08:47:18
1433
原创 实战1 - 空气质量数据的校准
1 题目简介题目来源于2019 高教社杯全国大学生数学建模竞赛D题。2 涉及内容在本次实战的数据分析过程中,涉及以下技术内容:主要使用以下MATLAB功能实现:3 实战步骤3.1 数据读取读取数据,查看数据基本情况,warning("off");Data_1=readtable("附件1.csv");Data_2=readtable("附件2.csv");size(Data_1)size(Data_2)输出3.2 去除重复值去除时间戳重复的行,因为之后的插值和回归都属于
2022-05-31 07:58:18
5963
2
原创 【MATLAB编程实例练习】-(43)找出0的长度和位置
题目来源于Mathwork上的Cody,Problem 1779 - Oh Zero Zero Zero!!!你需要找到向量中是0的部分,然后找到这些零的长度和起始位置。。。例如:x = [1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0 0 0 9 8 7 6 5 4 3 2 1];%then the output is:LP = [9 10] %[Length Position]%Or another example:x = [1 0 3 49 3 2 232 3 0 0 0
2021-11-04 16:45:34
1050
原创 【MATLAB编程实例练习】-(42)斐波那契数列的分解
题目来源于Mathwork上的Cody,Problem 42340 - Fibonacci Decomposition.Every positive integer has a unique decomposition into nonconsecutive Fibonacci numbers f1+f2+ … Given a positive integer n, return these numbers.Return the vector f = [f1, f2, …] sorted from s
2021-10-27 10:42:16
505
原创 【MATLAB编程实例练习】-(41)标记变化幅度大的位置
题目来源于Mathwork上的Cody,Problem 729 - Flag largest magnitude swings as they occur.You have a phenomenon that produces strictly positive or negative results.delta = [1 -3 4 2 -1 6 -2 -7];Marching through this list from beginning to end, mark a value with -1
2021-10-25 13:46:44
235
原创 【MATLAB编程实例练习】-(40)画出“E”字形矩阵
题目来源于Mathwork上的Cody,Problem 44679-Draw ‘E’.Draw a x-by-x matrix ‘E’ using 1 and 0. (x is odd and bigger than 4)Example:x=5ans=[1 1 1 1 11 0 0 0 01 1 1 1 11 0 0 0 01 1 1 1 1]x=7ans=[1 1 1 1 1 1 11 0 0 0 0 0 01 0 0 0 0 0 01 1 1 1 1 1 11 0 0
2021-10-23 13:30:27
650
原创 【MATLAB编程实例练习】-(39)数字之和
题目来源于Mathwork上的Cody,Problem 20 - Summing digits.给定n,求构成2^n的数字之和。例如,输入n=7,则输出b=11,因为2^7=128,1+2+8=11。代码function b = sumDigits(n) b = 0; a=2^n; a_str=num2str(a); for i=1:length(a_str) b=b+str2double(a_str(i)); endend其它优秀代码function
2021-09-08 10:16:16
1690
原创 【MATLAB编程实例练习】-(38)找到将向量等分为两半的子集
题目来源于Mathwork上的Cody,Problem 660 - Find a subset that divides the vector into equal halves.Given a vector x, return the indices to elements that will sum to exactly half of the sum of all elements.Example:Input x = [1 2 3 4 5 6 7]Output xi = [1 6 7]
2021-09-07 14:08:37
228
原创 【MATLAB编程实例练习】-(37)移动0到顶端
题目来源于Mathwork上的Cody,Problem 112 - Remove the air bubbles.Given a matrix a, return a matrix b in which all the zeros have “bubbled” to the top. That is, any zeros in a given column should be moved to the top. The order of the remaining nonzero numbers in
2021-09-04 14:08:06
285
原创 【MATLAB编程实例练习】-(36)删除所有以“ain”结尾的单词
题目来源于Mathwork上的Cody,Problem 31 - Remove all the words that end with “ain”.Given the string s1, return the string s2 with the target characters removed.For example, givens1 = ‘the main event’your code would returns2 = ‘the event’Note the 2 spaces be
2021-09-03 15:19:00
180
原创 【MATLAB编程实例练习】-(35)判断点是否位于三角形内
题目来源于Mathwork上的Cody,Problem 558 - Is the Point in a Triangle?Check whether a point or multiple points is/are in a triangle with three cornersPoints = [x, y];Triangle = [x1, y1; x2, y2; x3, y3]Return true or false for each point tested.For example,in
2021-09-03 10:02:26
964
原创 【MATLAB编程实例练习】-(34)直角三角形边长问题
题目来源于Mathwork上的Cody,Problem 1103 - Right Triangle Side Lengths.If p is the perimeter of a right angle triangle with integral length sides, { a, b, c }, there are exactly three solutions for p = 120.{[20,48,52], [24,45,51], [30,40,50]}Given any value of
2021-09-02 16:58:40
1079
原创 【MATLAB编程实例练习】-(33)寻找数组最近的数(Nearest Numbers)
题目来源于Mathwork上的Cody,Problem 29 - Nearest Numbers.Given a row vector of numbers, find the indices of the two nearest numbers.Examples:[index1 index2] = nearestNumbers([2 5 3 10 0 -3.1])index1 =1index2 =3[index1 index2] = nearestNumbers([-40 14 22 1
2021-09-01 14:07:18
580
原创 【MATLAB编程实例练习】-(32)最长连续数(Longest run of consecutive numbers)
题目来源于Mathwork上的Cody,Problem 672 - Longest run of consecutive numbers.Given a vector a, find the number(s) that is/are repeated consecutively most often. For example, if you havea = [1 2 2 2 1 3 2 1 4 5 1]The answer would be 2, because it shows up three
2021-08-31 09:14:55
681
原创 【MATLAB编程实例练习】-(31)制作棋盘矩阵(Make a checkerboard matrix)
题目来源于Mathwork上的Cody,Problem 4 - Make a checkerboard matrix.Given an integer n, make an n-by-n matrix made up of alternating ones and zeros as shown below. The a(1,1) should be 1.Example:Input n = 5Output a is [1 0 1 0 10 1 0 1 01 0 1 0 10 1 0 1 0
2021-08-28 16:02:20
690
原创 【MATLAB编程实例练习】-(30)Knight‘s Tour Checker(马走日)
题目:来源于Mathwork上的Cody,Problem 96 - Knight’s Tour Checker,Given a matrix a, determine whether or not a legal knight’s tour is present. The knight’s tour always follows the pattern 1, 2, 3, … but it need not fill the entire matrix. Any unused squares contai
2021-07-09 08:55:20
359
原创 【MATLAB编程实例练习】-(29)数组中元素出现次数的计数
题目:来源于Mathwork上的Cody,Problem 55 - Counting Sequence,代码实现,function y = CountSeq(x)if length(x)==1 y=[1,x];else a=1;b=x(1);y=[]; for i=2:length(x) if x(i)==x(i-1) a=a+1; else y=[y,
2021-07-06 19:10:21
385
原创 【MATLAB编程实例练习】-(28)具有公约数的最长数组
题目:来源于Mathwork上的Cody,Problem 84 - Longest Divisor Run,想得比较复杂了,下面画个简图帮助理解下,代码,function [len,d] = divisor_run(a) for j=1:length(a)-1 D(1,j)=gcd(a(j),a(j+1)); end for i=2:length(a)-1
2021-07-05 22:07:39
142
原创 【MATLAB编程实例练习】-(27)子集之和
题目:来源于Mathwork上的Cody,Problem 43. Subset Sum,我主要使用nchoosek函数生成各种组合,然后借助sum函数寻找与n相等的组合。代码如下,function ind = subset_sum(v,n) index=1:1:length(v); ind=[]; if sum(v==n)>0 ind=index(v==n); end if isempty(ind) for i=len
2021-07-04 14:32:24
339
原创 【MATLAB编程实例练习】-(26)靶心矩阵的生成
题目:来源于Mathwork上的Cody,Problem 18 - Bullseye Matrix,我是采用从外圈到内圈逐渐生成的方式,以 n=5 为例,第一次循环,生成 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3第二次循环,生成
2021-07-04 10:16:35
349
原创 【MATLAB编程实例练习】-(25)在数组中寻找离给定数最近的数
题目:来源于Mathwork上的Cody,Problem 51610 - Find the nearest value to the given one,该题主要考察数组与标量的算术运算、min函数、数组元素的访问,function y = nearest_value(vec,val) [M,I]=min(abs(vec-val)); y = vec(I);end测试,nearest_value([17 7 11 10 12 4],9)ans = 10...
2021-07-03 23:04:32
616
原创 【MATLAB编程实例练习】-(24)元胞cell数组乘法的实现
题目:来源于Mathwork上的Cody,Problem 44245,Cell Operator *,实现的过程比较简单,使用了repmat函数。函数构造如下,function out_A = m_times(A, n)%STAY HOME, STAY SAFE%WEAR A MASKif length(n)==1 N=[1,n];else N=n;endout_A=repmat(A,N);end测试如下, m_times({2,3},2)ans =
2021-07-03 22:38:46
3000
原创 【3】简单粗暴MATLAB中文文本分类
最近探索了用MATLAB进行文本分类,没有涉及高级和复杂的算法公式,仅发出来和大家分享下。数据集数据是关于新闻分类的,总共包括财经、房产、家居、教育、科技、时尚、时政、体育、游戏、娱乐10种类型的新闻。训练集共10000行数据。目标使用MATLAB训练分类器,实现对新闻文本的分类。步骤1、使用数据导入功能将训练集导入workspace,导入类型为tabel类型,整个table命名为train,第一列为response(分类目标,categorical类型),第二列为新闻描述文本(string类
2021-06-29 20:40:00
3550
3
原创 【1】使用分类学习APP - Classification Learner App 训练分类模型
什么是有监督学习?你可以使用分类学习器训练模型来对数据进行分类。使用这个APP时,你可以通过使用各种分类模型来探索监督机器学习。你可以浏览数据、选择特征、指定验证方案、训练模型和评估结果。你可以执行自动训练来寻找最佳的分类模型,包括决策树、判别分析、支持向量机、逻辑回归、最近邻和集成分类器等等。...
2021-06-14 14:50:51
1809
6
原创 【4】NumPy基础
#Numpy Numpy最重要的一个特点就是其N维数组对象,import numpy as npdata=np.random.randn(2,3)dataarray([[ 0.24196957, -0.53141846, -0.1848278 ], [-0.59430093, 0.71353871, 1.25313374]])#然后进行数学运算,data*10array([[ 2.41969565, -5.3141846 , -1.84827803], [-
2021-05-05 10:57:27
195
原创 【3】数据结构之字典、集合
字典字典可能是Python最为重要的数据结构。它更为常见的名字是哈希映射或关联数组。它是键值对的大小可变集合,键和值都是Python对象。创建字典的方法之一是使用尖括号,用冒号分割键和值,empty_dict={}d1={'a':'some value','b':[1,2,3,4]}d1{'a': 'some value', 'b': [1, 2, 3, 4]}你可以像访问列表或元组中的元素一样,访问、插入或设定字典中的元素,d1[7]='an integer'd1{'a': 'so
2021-02-12 17:22:07
399
原创 【2】数据结构之列表、列表函数
切片用切片操作可以选取序列的一部分数据,切片的基本形式是在方括号中使用start:stop:seq=[7,2,3,7,5,6,0,1]seq[1:5][2, 3, 7, 5]切片也可以被序列赋值:seq[3:4]=[6,3]print(seq)[7, 2, 3, 6, 3, 5, 6, 0, 1]切片操作是“包头不包尾”。start或stop都可以被省略,省略之后,默认为序列的开头和结尾,seq[:5][7, 2, 3, 6, 3]seq[3:][6, 3, 5, 6
2021-02-12 16:58:45
367
原创 【6】决策树
决策树广泛用于分类和回归问题。比如我们要区分四种动物:鹰、企鹅、海豚、熊,我可以由几个if/else来判断,import numpy as npimport pandas as pdimport mglearnimport matplotlib.pyplot as pltimport graphvizfrom sklearn.model_selection import train_test_splitmglearn.plots.plot_animal_tree()注意,如果报错“py
2021-02-10 10:50:49
496
1
原创 【5】线性分类器
将Logistic回归和线性支持向量机应用到forge数据集上,import numpy as npimport pandas as pdimport mglearnimport matplotlib.pyplot as pltfrom sklearn.model_selection import train_test_splitfrom sklearn.linear_model import LogisticRegressionfrom sklearn.svm import LinearS
2021-02-08 13:15:49
245
数学建模国赛优秀论文集1992-2017.rar
2020-07-07
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人