Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
How to compare two lists
Réponse acceptée
19 commentaires
"Umer: you want to output zero if a is not a member of b, but this answer does not do that."
Huh?
>> b =[1 2 3 4 5 ]
b =
1 2 3 4 5
>> a = [1 2 7]
a =
1 2 7
>> a .* ismember(a,b)
ans =
1 2 0
mask = ~ismember(a, b); c = a;
then
c(mask) = 2; %change the missing items to the fixed value 2
or
c(mask) = a(mask) - 1; %change the missing items to one less than their original value
- if the datatypes are uint8, int16, or int32, then the code assumes you knew what you were doing with the range of values and leaves them completely unchanged
- if the range of values is -1 to +1 then the code assumes you knew what you were doing with the range of values and leaves them unchanged, but alters the datatype to double. The cases where the data type could end up altered are single() that are in the right range, and int64(). The way the code is set up cannot affect the other integer data types
- if the values are all non-negative, then the code assumes you knew what you were doing about the lower end of the values, and rescales [0 max(c)] to [-1 +1] . So, for example, your range of values happened to be 30000 to 50000 then this will be mapped first to [30000/50000, 50000/50000] and then the [0 1] range would be mapped to [-1 +1] so the [30000/50000, 50000/50000] would end up mapping to [1/5 1]. It would also have been entirely reasonable to instead map [min(c) max(c)] to [-1 +1]: in the absence of information from you about what should be done, a decision had to be made
- otherwise, in the case where there was a mix of positive and negative values but the range was outside [-1 +1], the code scales [min(c) max(c)] to [-1 +1]
Plus de réponses (0)
Voir également
Catégories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asie-Pacifique
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
