matlab 怎么把不同長度的向量存放在同一個矩陣中
matlab 怎么把不同長度的向量存放在同一個矩陣中
其他人氣:486 ℃時間:2020-06-05 18:31:18
優(yōu)質解答
代碼:-----------------------------------------a=1:10;b=1:20;num=[];num=[num length(a)];num=[num length(b)]; %依次類推m=length(num);n=max(num);c=zeros(m,n)*1/0; %用無窮大填充NaN%c=zeros(m,n); %用零填...如果用for循環(huán)呢?for i = 1:10;A = 1:2:2*i;end怎樣把每次產(chǎn)生的向量A存到一個矩陣B里面?在原程序上稍微改改就是了唄。如果不介意內(nèi)存消耗的話,可以事先定義一個超大的數(shù)組,在最后再取出來。clc;clear;closeB=zeros(100,100)*1/0;row=10;num=[];for i=1:rowA=[];A = 1:2:2*i;num=[num length(A)];B(i,1:length(A))=A;endcolumn=max(num);C=B(1:row,1:column)結果:-----------------------------------------C = 1 NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 3 NaN NaN NaN NaN NaN NaN NaN NaN 1 3 5 NaN NaN NaN NaN NaN NaN NaN 1 3 5 7 NaN NaN NaN NaN NaN NaN 1 3 5 7 9 NaN NaN NaN NaN NaN 1 3 5 7 911 NaN NaN NaN NaN 1 3 5 7 91113 NaN NaN NaN 1 3 5 7 9111315 NaN NaN 1 3 5 7 911131517 NaN 1 3 5 7 91113151719
我來回答
類似推薦
- matlab中怎么將一個矩陣變?yōu)橐粋€行向量
- Matlab中,矩陣、向量和標量有何關系?有何區(qū)別?
- matlab 怎么把行向量轉成 矩陣向量?
- 在matlab里怎么求向量的長度
- 在matlab中怎樣求矩陣的特征向量
- 判斷一個數(shù)是質數(shù)還是合數(shù),要看它什么
- 酬樂天揚州初逢席上見贈中寄希望于未來的哲理詩句是什么
- Whether i go or not,we are the best
- Are ther any books in the bag?Yes,there is__________. A.it B. one C. any D. some
- it`s cool here because wind can blows in ( ) the two windows
- 如圖,是一個幾何體的三視圖,那么這個幾何體是_.
- ”秋處露秋寒霜降”是二十四節(jié)氣歌中的一句,其中第二個”秋”指的是
猜你喜歡
- 1即是兩大洋分界線又是兩大洲分界線的海峽是哪個?
- 2甲數(shù)除以乙數(shù),商是5分之2,甲數(shù)與乙數(shù)的和是21,甲數(shù)是(),乙數(shù)是()
- 3已知f(x)=ax2+bx(a≠0)滿足f(x-1)=f(3-x)且方程f(x)=2x有兩個等根,求f(x)的解析式.
- 4請問有關趙州橋的傳說有哪些?
- 5關于interest 的英語改錯
- 6God made the integers; all else is the work of man什么意思
- 7方程0.02分之0.2x-0.2 -0.5分之x+1=3的解是()
- 8多少硫酸和多少氯化鉀高溫后反映出多少硫酸鉀和多少鹽酸.
- 9in my home all the chairs are made of b_____
- 10雷諾實驗中如何正確設置高位水槽
- 11一只掛鐘的時針長10厘米 急!
- 12they want to buy some fruit .對劃線部分提問(some fr