Building a matrix with a varying column length

2 ビュー (過去 30 日間)
Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013 年 1 月 24 日
I am trying to build a matrix whose rows are as many as the length of D (see below) and whose columns vary. Because this is impossible I tried to preallocate the size of the matrix trying to fill it with zeros. Unfortunately I get the following error:
Subscripted assignment dimension mismatch.
Below you can see my code
n=1:1:2;
D(:,1)=L./(2.*n);
% Wf=20*10^-6:10^-6:L;
% S=zeros(size(Wf));
Wfmin=20e-6;
Wf_step=1e-6;
Wfmax=2*max(D);
size=length(Wfmin:Wf_step:Wfmax);
for i=1:length(D)
Wf=zeros(i,size);
Wf(i,:)=20e-6:1e-6:2*D(i);
end

採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 24 日
T = 20e-6:1e-6:2*D(i);
Wf(i, 1:length(T)) = T;

その他の回答 (1 件)

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2013 年 1 月 24 日
Thank you Walter

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by