%%學習目標: 1 資料型別的強制轉換,數值範圍
%% 2 取整函式的使用學習
%% 3 複數的使用學習
%%clear all;
%%shu=66; %雙精度浮點型,強制轉換成整型
shu8=int8(shu)
shu16=int16(shu)
shu32=int32(shu)
shu64=int64(shu)
zifuchuan=『daxian』
huan1=int8(zifuchuan)
%% 學以致用,whos 一下
%%fudian=14.89 %預設是雙精度浮點型
fusingle=single(fudian) %轉換成單精度浮點型
fudouble=double(fudian) %轉換成雙精度浮點型
%% 檢視資料型別的數值範圍
singlefanwei=[realmin(『single』) realmax(『single』)]
doublefanwei=[realmax(『double』) realmax(『double』)]
%% 數值的取整
round1=round(8.5) %最接近取整,0.5為臨界條件
round2=round(-6.4)
round3=round(-6.5)
fix1=fix(-1.6) %向0取整
fix2=fix(-1.5)
floor1=floor(2.7) %小於或者等於該數的接近整數
floor2=floor(-2.4)
ceil1=ceil(4.2) %大於或者等於該數的接近整數
ceil2=ceil(-4.4)
%% 複數的學習
fushu1=3+4i
real1=real(fushu1) %求複數的實部
imag1=imag(fushu1) %求複數的虛部
abs1=abs(fushu1) %求複數的模
angle1=angle(fushu1) %求複數的角度
gonge=conj(fushu1) %求它的共軛複數
1 精通MATLAB變數型別看這篇就夠了
學習目標 1.掌握matlab程式設計中最常用的幾種變數型別 2.對變數型別的屬性有所熟悉,不要求記憶,知道了解即可 3.要求熟練運用這幾種變數型別建立自己的變數 clear all 清除workspace中的所有變數 clc 清除command window中的所有命令 在matlab中數字可以直...
matlab資料型別
數字 字元與字串 都用單引號 s a str i love matlab machine learning.abs s 絕對值函式,可以用來檢視字元的ascii char 65 ascii轉換成字元 num2str 65 數字轉換成字串 3.矩陣 a 1 2 3 4 5 2 3 2 7 b a 轉置...
matlab資料型別
matlab中支援的資料型別包括 邏輯 logical 字元 char 數值 numeric 元寶陣列 cell 結構體 structure table 函式控制代碼 function handle 該型別變數值為1或0 matlab的字元型輸入需使用單引號,字串儲存為字元陣列,每個元素佔乙個asc...