How to construct array with certain slope ?

Dear Team,
I have a signal :
Signal = [ 0,10, 0, 10, 0, 10, -50, -10,-50,-10,-50, 30, 20, 30, 20] ;
Signal is y-axis values and i want to define x-axes values based on slope of incline and decline.
incline & decline slope to be 10%.
I would like to first scale the x-axes then interpolate 10 points in between them.
I want to plot such that its incline and declipne slope is 10 or any other user defined value ?
Can you please support in getting that slope part in signal ?

5 件のコメント

Jan
Jan 2021 年 5 月 4 日
How do you define "incline slope"? 10%, 10 degree, tangens? Do you want to insert additional point to achieve, what you want, or scale the axes?
NIKHIL
NIKHIL 2021 年 5 月 5 日
SIgnal is y-axis values and i want to find x-axes values based on slope of incline and decline.
incline & decline slope to be 10%.
I would like to first scale the x-axes then interpolate 10 points in between them.
Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 5 日
I assumed that the signal were the Y-values, and I assumed that the X-values were just the indices from 1 to 10. I do not understand what you mean by "find x-axes values based on slope of incline and decline". Do you have a simple example showing before and after pictures? I am not clear what kind of slope you need for your Signal.
Signal = [ 0,10, 0, 10, 0, 10, -50, -10,-50,-10,-50, 30, 20, 30, 20] ;
plot(Signal)
NIKHIL
NIKHIL 2021 年 5 月 5 日
when i say slope =10 means
0 to 10 it will take 1 secs while going from -50 to -10 will take 4 secs time
Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 5 日
編集済み: Paul Hoffrichter 2021 年 5 月 5 日
>> 0 to 10 it will take 1 secs
Sounds like 10 means 10 seconds, but elsewhere you refer to 10%. I still do not understand what the plot should look like. Are you looking to rotate the plot or just scale the x-axis.
Maybe clarify exactly what the axis should look like as a first step.

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

回答 (1 件)

Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 5 日

0 投票

5 件のコメント

NIKHIL
NIKHIL 2021 年 5 月 5 日
Paul,
Signal is y-axis values and i want to find x-axes values based on slope of incline and decline.
incline & decline slope to be 10%.
I would like to first scale the x-axes then interpolate 10 points in between them.
**modified the question slightly..added more info.
Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 5 日
Is this closer to what you are looking for?
Signal = [ 0,10, 0, 10, 0, 10, -50, -10,-50,-10,-50, 30, 20, 30, 20] ;
t = [ 0 1 2 3 4 5 6 10 11 15 16 24 25 26 27];
plot(t, Signal,'-b.'), xlabel('seconds'), axis tight, grid on, grid minor
NIKHIL
NIKHIL 2021 年 5 月 6 日
Yes I am looking for this but 't' should be derived from Signal values.
Signal values may vary across different signal.
How to estimate 't' array from Signal ?
Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 6 日
編集済み: Paul Hoffrichter 2021 年 5 月 6 日
't' was my guess. Is 't' as written the exact values you want to compute? Or, are there some modifications that you would like to see to 't' ? After confirmed, I will see if I can derive 't' from the particular signal. Since signal values will vary, it would be helpful with another short signal, and then indicate what the value of 't' should be for that new signal. This may help to generalize the function to produce 't'.
Are all signal values multiple of 10? If not, this could affect the results.
t = [ 0 1 2 3 4 5 6 10 11 15 16 24 25 26 27];
stem(t)
Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 15 日
NIKHIL,
Since the values of 't' in previous post is what you can use, here is a formulation of how to get those values.
Signal = [ 0,10, 0, 10, 0, 10, -50, -10,-50,-10,-50, 30, 20, 30, 20] ;
difSig = [0 diff(Signal)/10];
t = zeros(1, length(difSig));
for ii = 2:length(t)
if difSig(ii) < 0
t(ii) = t(ii-1) + 1;
else
t(ii) = difSig(ii) + t(ii-1);
end
end
plot(t,Signal), axis tight, grid on, grid minor
Hope this helps.

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

カテゴリ

製品

質問済み:

2021 年 5 月 4 日

コメント済み:

2021 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by