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.

Error in rescale (line 36)
[A, a, b, inputMin, inputMax] = preprocessInputs(A, varargin{:});

 採用された回答

Steven Lord
Steven Lord 2025 年 5 月 9 日

0 投票

From the rescale documentation page: "R = rescale(A,l,u) scales all elements in A to the interval [l u]."
The second input argument must be less than or equal to the third input argument. In your call, that is not satisfied. Swap the order of the 1 and -1.

8 件のコメント

shamal
shamal 2025 年 5 月 9 日
excuse me..it's possible to reconvert normalize series in the original series?
Steven Lord
Steven Lord 2025 年 5 月 9 日
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?
shamal
shamal 2025 年 5 月 9 日
編集済み: shamal 2025 年 5 月 9 日
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
shamal
shamal 2025 年 5 月 9 日
編集済み: shamal 2025 年 5 月 9 日
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
Steven Lord
Steven Lord 2025 年 5 月 9 日
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
shamal
shamal 2025 年 5 月 10 日
編集済み: shamal 2025 年 5 月 10 日
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
Voss
Voss 2025 年 5 月 10 日
@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>
shamal
shamal 2025 年 5 月 10 日

Thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTime Series についてさらに検索

製品

リリース

R2024b

質問済み:

2025 年 5 月 9 日

コメント済み:

2025 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by