Units help to plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nina Perf
le 20 Sep 2021
Modifié(e) : Nina Perf
le 22 Sep 2021
I want to convert values in a table column to a range of -1 to 1 units.
My -1 value is -800
My 0 value is 300
My 1 value is 800
The column values go from 0 to 800.
How can I do this?
Thanks!
1 commentaire
the cyclist
le 20 Sep 2021
Modifié(e) : the cyclist
le 20 Sep 2021
x = [-800 300 800];
y = [-1 0 1];
figure
h = plot(x,y,'.:');
set(h,'MarkerSize',32)
Nina, an infinite number of curves can be drawn through the three points you have specified. None of them are linear (so it is not what I would think of as a simple "conversion".)
Do you have any additional information that would be helpful in what you are trying to do? As I have mentioned in another of your questions, please try to be complete in what you are asking for.
Réponse acceptée
Walter Roberson
le 21 Sep 2021
values = randi([0 800], 1, 10)
b = [-800 300 800];
mask = values < b(2);
scaled(mask) = (values(mask)-b(1))./(b(2)-b(1));
scaled(~mask) = (values(~mask)-b(2))./(b(3)-b(2));
scaled
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!