How do I assign values to a matrix?
古いコメントを表示
I have a 6×37 matrix of values ranging from 1-6 which are classes. stability_class is attached.
I want to assign values to four matrices a,b,d,e to be the same dimension with stability_class and have different entries when stability_class changes from 1-6 across rows and columns.
a=zeros(size(X));
b=zeros(size(X));
d=zeros(size(X));
e=zeros(size(X));
[c,f]=find(stability==1);
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k),2)=0.32;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.24;
e(i(k,1),j(k,2))=0.0001;
end
[c, f]=find( stability==2);
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k,2))=0.32;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.24;
e(i(k,1),j(k,2))=0.0001;
end
[c,f]=find(stability==3) ;
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k,2))=0.16;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.12;
e(i(k,1),j(k,2))=0.00;
end
[c,f]= find(stability==4);
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k,2))=0.16;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.12;
e(i(k,1),j(k,2))=0.00;
end
[c,f]=find(stability==5);
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k,2))=0.16;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.14;
e(i(k,1),j(k,2))=0.0003;
end
[c,f]=find(stability==6);
ind=[c,f];
i=ind(1:end,:);
j=ind(:,1:end);
for k=1:size(c,1)
a(i(k,1),j(k,2))=0.11;
b(i(k,1),j(k,2))=0.0004;
d(i(k,1),j(k,2))=0.08;
e(i(k,1),j(k,2))=0.0015;
end
But I get a 3D array(x:y:z) for a with uncompleted matrices for b,d,e.
2 件のコメント
KSSV
2020 年 8 月 28 日
Question is not clear. What output you expect?
Aduloju Oluwatobi
2020 年 8 月 28 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Geometric Transformation and Image Registration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!