フィルターのクリア

scaling down 0x axis coordinates of a graphic

2 ビュー (過去 30 日間)
kerozi
kerozi 2016 年 5 月 3 日
回答済み: kerozi 2016 年 5 月 4 日
Hello all,
I was wondering how to scale down, 50, 0x axis coordinates of a function that are between [0,100] interval to [0,1] interval without harming the spacing ratios of ascending coordinates.
For instance; vector's values are 0 1 2 3 4 5 6 7 8 9 10 and I want them to be in [0,1] interval. hence the values become 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 and 1.0.
Of course the easy answer would be just to multiply the answer by necessary coefficient (which is in this case 0.1). But I think there are a lot of better answers that I seek particularly.
And I'm sorry for language mistakes in advance.
A=logspace(1,0,50) %I created an initially dense 50 0x coordinates
B=exp(A) %then make it denser
C=B/1e+04 %and tried to make values smaller or tuck them into non specific interval.
Main purpose of this question is whether MATLAB can create an array vector between 0 and 1 with the element number of 50 or 100, with a scattered spacing from beginning '0' to end value '1'. For example: [ 0 0.0125 0.0250 0.0500 0.0750 0.1 0.1500 0.2 0.3 0.45 0.575 0.6 0.650 0.700 0.7250 0.750 0.775 0.8 0.8250 0.850 0.875 0.9 0.9125 0.9250 0.950]
So sorry for long post. If there are something vague term. I'd happy to answer.
Thank you so much for even considering to answer.

回答 (3 件)

J. Webster
J. Webster 2016 年 5 月 3 日
編集済み: J. Webster 2016 年 5 月 3 日
Is this what you're looking for?
x = 1:.5:56; %example initial array with spacing of 1/2 from 1 to 56
%subtract the first value from the entire array so that it now starts at 0
x = x-x(1);
%now divide the array by the value of the last point, so that the entire thing will go 0 to 1;
x = x./x(end);
  1 件のコメント
kerozi
kerozi 2016 年 5 月 3 日
This is not the particular answer that I am looking for but it definitely expanded the horizon. This codes' problem was the differences between x values were uniform. '0.091'. But as I said definitely expanded the view because it keeps the number of points same but it limits the xmin and xmax with a coefficient. Thank you for answering my delusional question.

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


Azzi Abdelmalek
Azzi Abdelmalek 2016 年 5 月 3 日
Look at this example
t=0:100;
y=sin(t);
plot(t,y)
xl=xlim;
xtn=0:0.125:1
set(gca,'xtick',linspace(xl(1),xl(2),numel(xtn)))
xtln=arrayfun(@(x) num2str(x),xtn,'un',0)
set(gca,'xticklabel',xtln)
  1 件のコメント
kerozi
kerozi 2016 年 5 月 4 日
Yet again it creates the array with a uniformly spaced way. 0 to 100 interval turned out to be 0 to 1 interval, which is really good. But the the spacing is 'uniform', 0.125. Not the way I want it to be.
'with a scattered spacing from beginning '0' to end value '1''

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


kerozi
kerozi 2016 年 5 月 4 日
Mr Abdelmalek's code scaled down the array s interval uniformly spaced way which is a good thing thus I problems first phase is complete but the spacing should ve been denser at the beginning, as if its an array like [0 0.0125 0.025 0.0375 ... 0.8 0.9 1] .

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by