Matlab 常用小問題解決記錄

1.cell轉char字符串

//data爲cell
tmp=data{i};
%將data第i個轉爲char字符串存於tmp

2.字符轉數字

%str爲該數字字符
num=str2num(str);
%num=str2double(str);%會faster

3.讀取位於excel的文本以及數據

[data,text]=xlsread(filename);
%data存放數據矩陣,text存放的格式爲cell

4.xlswrite寫入不同sheet不同列

xlswrite(filename,data,'sheet1','A');

5.設置圖像標籤

axis(x_low,x_high,y_low,y_high);%圖像顯示範圍
legend('line1name','line2name');%加示例
grid on;%加網格

6.取整

floor(num);%向下取整
ceil(num);%向上取整
around(num);%四捨五入
fix(num);%向0取整

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章