フィルターのクリア

Need to Produce a different size matrix on each iteration

1 回表示 (過去 30 日間)
DARLINGTON ETAJE
DARLINGTON ETAJE 2021 年 6 月 28 日
コメント済み: DARLINGTON ETAJE 2021 年 6 月 28 日
Good Morning,
I need your urgent help. I have a presentation on this in a few hours. I am trying to create one matrix concatenated to the previous per loop.
the concept is that the abc first matrix is [1 51]. the second matrix is [1 51;2 52]; the third matrix is [1 51;2 52;3 53]; and so on.
wqe=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
kli=[51;52;53;54;55;56;57;58;59;60;61;62;63;64;65];
hsd=size(kli,1);
kas=zeros(hsd,1);
sak=zeros(hsd,1);
abc=repmat({zeros(hsd,1)},hsd,1);
for i=1:hsd
kas(i)=wqe(i);
sak(i)=kli(i);
end
for h=2:1:hsd
abc{i}=[kas(i-1) sak(i-1);kas(i) sak(i)];
end

採用された回答

Alan Stevens
Alan Stevens 2021 年 6 月 28 日
Try the following
wqe=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
kli=[51;52;53;54;55;56;57;58;59;60;61;62;63;64;65];
hsd=size(kli,1);
kas=zeros(hsd,1);
sak=zeros(hsd,1);
abc=zeros(hsd,2);
for i=1:hsd
kas(i)=wqe(i);
sak(i)=kli(i);
end
abc(1,:) = [kas(1) sak(1)];
for h=2:1:hsd
abc(h,:)=[kas(h) sak(h)];
end
disp(abc)
1 51 2 52 3 53 4 54 5 55 6 56 7 57 8 58 9 59 10 60 11 61 12 62 13 63 14 64 15 65
  3 件のコメント
Alan Stevens
Alan Stevens 2021 年 6 月 28 日
More like this?
wqe=[1;2;3;4;5;6;7;8;9;10;11;12;13;14;15];
kli=[51;52;53;54;55;56;57;58;59;60;61;62;63;64;65];
hsd=size(kli,1);
kas=zeros(hsd,1);
sak=zeros(hsd,1);
abc=zeros(hsd,2);
for i=1:hsd
kas(i)=wqe(i);
sak(i)=kli(i);
end
abc(1,:) = [kas(1) sak(1)];
for h=2:1:hsd
abc(h,:)=[kas(h) sak(h)];
end
matrix{1}=abc(1,:);
for i = 2:hsd
matrix{i}=abc(1:i,:);
end
DARLINGTON ETAJE
DARLINGTON ETAJE 2021 年 6 月 28 日
this response is correct. Thank you so much.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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