use rescale with matrix
显示 更早的评论
hi,i want to normalize matrix using interval -1 and 1
load('matlab_E');
B=rescale(E,1,-1);
Error using rescale>preprocessInputs (line 90)
Lower bound argument must be less than or equal to the upper bound argument.
Lower bound argument must be less than or equal to the upper bound argument.
Error in rescale (line 36)
[A, a, b, inputMin, inputMax] = preprocessInputs(A, varargin{:});
采纳的回答
Steven Lord
2025-5-9
8 个评论
excuse me..it's possible to reconvert normalize series in the original series?
I'm not sure I understand what you're asking. Are you asking if you can take the output of rescale and reverse the scaling to obtain the original array again? That would depend on whether or not you have some additional information about your original array.
x1 = [1 2 3 4 5]
x1 = 1×5
1 2 3 4 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
x2 = x1 + 100
x2 = 1×5
101 102 103 104 105
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
R1 = rescale(x1, 0, 1)
R1 = 1×5
0 0.2500 0.5000 0.7500 1.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
R2 = rescale(x2, 0, 1)
R2 = 1×5
0 0.2500 0.5000 0.7500 1.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
isequal(R1, R2)
ans = logical
1
Without any additional information, if I gave you R1 (which is the same as R2), how could you tell me if the original array was x1 or x2?
example: (look pics)
I need to calculate boolinger band (stdev) in series
to do this i want do normalize series and after i calculate boolinger band
Now i want to plot the band stdev but it's normalize, then i must to convert series normalize in series not normalize
in imagine.png you see original series and the boolinger Not nornalized
if i normalize series and calculate boolinger band using normalized i see a band in interval -1 1 and i don't plot it..
i must to reconvert to plot it
you write : "Without any additional information, if I gave you R1 (which is the same as R2), how could you tell me if the original array was x1 or x2?"
I 've information about the max and min of series and i can use it to reconvert series
Okay, so you want to rescale other data using the same scaling factors that were used on the original data? In that case perhaps the normalize function is what you want. Let's say I normalize a vector to cover the range [0, 1] and I ask for three outputs.
x = 10:15;
[y1, c, s] = normalize(x, "range")
y1 = 1×6
0 0.2000 0.4000 0.6000 0.8000 1.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
c = 10
s = 5
Now if I normalize one of the data points in x (without the rest) and use the outputs from the first normalize call I ought to get essentially the same value as the element in y1 corresponding to that data point in x.
y2 = normalize(x(4), "center", c, "scale", s) % ought to be essentially y1(4)
y2 = 0.6000
difference = y1(4)-y2 % essentially 0
difference = 1.1102e-16
ok thank you but if i've this serie normalize "0 0,2000 0,4000 0,6000 0,8000 1,0000"
i want to get :"10 11 12 13 14 15"
it's possibile? I didn't see this in your steps
@Luca Re: Given:
have = [0 0.2 0.4 0.6 0.8 1];
min_to_get = 10;
max_to_get = 15;
Here's the math that does what you want:
min_have = min(have);
max_have = max(have);
to_get = (have-min_have)./(max_have-min_have).*(max_to_get-min_to_get)+min_to_get
to_get = 1×6
10 11 12 13 14 15
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Or, here's the MATLAB function call to do it:
to_get = rescale(have,min_to_get,max_to_get)
to_get = 1×6
10 11 12 13 14 15
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Thank you
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Time Series 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
