Effacer les filtres
Effacer les filtres

Could anyone help me how to solve the following issue with respect to the following code

1 vue (au cours des 30 derniers jours)
jaah navi
jaah navi le 3 Juin 2019
Commenté : KSSV le 3 Juin 2019
code:
a= [4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0]
for i=1:size(a,2)
b=a(:,1:i)
iwant = reshape(b(randperm(numel(b))),size(b))
end
with respect to the code in for loop,
when the loop runs for the first time it takes the first column and reshape it and
when the loop runs for the second time it takes the first and second column and reshapes it.
But what i actually need is when the loop runs for the first time by taking the first column,reshape it ,should not be changed when the loop runs for the second time by taking the second column.
Could anyone please help me on it.

Réponses (1)

KSSV
KSSV le 3 Juin 2019
a=[ 4.7908 5.0104 5.1329 5.3186 5.3094 5.3070 5.4452 5.5001;
0.0958 0.0994 0 0 0.1848 0.2020 0.1851 0.2146;
0.0848 0 0.1469 0.1859 0.1767 0.1854 0.1856 0.1648;
0 0 0 0 0 0 0 0;
0 0.0896 0.1619 0.1351 0 0 0 0;
0 0 0 0 0 0 0 0] ;
[m,n] = size(a) ;
b = a ;
for i = 1:m
idx = randperm(n) ;
b(i,:) = a(i,idx) ;
end
  5 commentaires
jaah navi
jaah navi le 3 Juin 2019
when i run the code the output remains equal to input.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by