替換矩陣元素我有以下的字符串矩陣:與矢量MATLAB
encodedData=[1 0 1 1]
我想創建一個新的矩陣「mananalog」代替encodedData項= 1與[1 1 1 1]和0與[ - 1 -1 -1 -1]
最終基質mananalog將是:[1 1 1 1 -1 -1 -1 -1 1 1 1 1 1 1 1 1]
我使用嘗試以下代碼:
mananalog(find(encodedData=='0'))=[num2str(1*(-Vd)) num2str(1*(-Vd)) num2str(1*(-Vd)) num2str(1*(-Vd))];
mananalog(find(encodedData=='1'))=[num2str(1*(Vd)) num2str(1*(Vd)) num2str(1*(Vd)) num2str(1*(Vd))];
VD = 0.7
不過,我有以下錯誤:
In an assignment A(I) = B, the number of elements in B and I must be the same.
你知道的功能,從而做到這一點? (未使用)
它是一個字符串或數組?如果你在MATLAB中輸入'+ encodedData',你會得到什麼? –
@StewieGriffin encodedData是一個char矩陣[1001001001001100101010 ...] –
'Vd'的內容是什麼? – bushmills