Effacer les filtres
Effacer les filtres

hello, i have a mixed 297 spreadsheet of output classification data like 0, 1 and 2 , i want to change it 100, 010 and 001 respectively with some matlab command.thanks

1 vue (au cours des 30 derniers jours)
hello, i have a mixed 297 spreadsheet of output classification data like 0, 1 and 2 , i want to change it 100, 010 and 001 respectively with some matlab command.thanks
0 changes to 100
1 changes to 010
2 changes to 001
in the all uploaded data of 297 x 1.
Thanks
  2 commentaires
Michael Van de Graaff
Michael Van de Graaff le 1 Avr 2021
So you want to take an integer n and produce a string (of what length) with all zeros but with a 1 at the (n+1)th position?

Connectez-vous pour commenter.

Réponses (1)

Shubham Khatri
Shubham Khatri le 12 Avr 2021
Modifié(e) : Shubham Khatri le 12 Avr 2021
Hello,
To my understanding, you want to replace the 0,1,2 with 100, 010 and 001 respectively. I am assuming that the numbers to be replaced are 0,1,2 only. For this, please find the code below for your assistance.
clear all
clc
A=[0 1 2 1 2 1 0]
B={}
for k=1:numel(A)
if A(k)==0
B{k}='100';
disp(B);
end
if A(k)==1
B{k}='010';
disp(B);
end
if A(k)==2
B{k}='001';
disp(B);
end
end
Hope it helps

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by