i need to code speed ..anyone can help me? Getting rid of the loop would be a good start
2 ビュー (過去 30 日間)
古いコメントを表示
v=[1 0 0 1];
d=[0.3 0 0 0.4]
n="lp";
count=1;
gg=find(v)
clear b
g={'Cycle n.',count}
j=1; %
for h=1:numel(gg)
b{j,h}={[g,gg(h),d(gg(h))]};
end
6 件のコメント
Bruno Luong
2023 年 9 月 4 日
編集済み: Bruno Luong
2023 年 9 月 4 日
But you have very bad start. This data organization is awful. We warn you, with such data you'll have speed, memory, and coding problems later.
採用された回答
Bruno Luong
2023 年 9 月 4 日
clear
v=[1 0 0 1];
d=[0.3 0 0 0.4];
count=1;
gg=find(v);
g={'Cycle n.',count};
j=1;
clear b
for h=1:numel(gg)
b{j,h}={[g,gg(h),d(gg(h))]};
end
% you want horrible code to store horrible data, here we go
bb = num2cell(num2cell([ repmat(g,[numel(gg) 1]) num2cell([ gg' d(gg)' ])], 2)');
isequal(bb,b)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!