필터 지우기
필터 지우기

Re-sizing vectors?

조회 수: 1 (최근 30일)
Vittorio Rossi
Vittorio Rossi 2018년 5월 19일
댓글: Ameer Hamza 2018년 5월 20일
I am working on a project that works with angles, and I have at my disposal a vector, that shows the angle elaborated and acquired from a sensor.
The only problem is that when I plot the vector, the y-axis has different values from the eulerian angle (see the image attached). I know which sample stands for the maximum angle and which sample stands for the minimum angle, but I can't find a way to " re-sizing" the vector by associating maximum and minimum angle and change all the samples variating within that range.
Does anyone have any suggestions on the code? Perhaps a function?
Thank you in advance for your time MatLAB community!!

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 19일
If you want to change the range of the y-values, you can do it by first normalizing and then denormalizing to your required range
x = [1xn signal]
xNormalized = (x-min(x))/(max(x)-min(x))
newMin = 0;
newMax = 90; % new minimum and maximum value of the signal you want
xNew = xNormalized*(newMax - newMin) + newMin;
xNew will have same shape of x but varies from newMin to newMax.
  댓글 수: 2
Vittorio Rossi
Vittorio Rossi 2018년 5월 20일
Thank you so much! It works!
Ameer Hamza
Ameer Hamza 2018년 5월 20일
You are welcome.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2018년 5월 19일
When you call the plot function with one input argument, the X coordinates used for the plot are the indices. In this example, V(1) is plotted at x = 1, V(2) at x = 2, etc. I added the line and marker specification to make it easier to see the actual points plotted.
figure
V = 1:2:19;
plot(V, '-o') % X coordinates 1:10
If instead you wanted to plot V(1) at x = 0.5, V(2) at x = 1, V(3) at x = 1.5, etc. you need to specify the vector of x coordinates in your plot call like this:
figure
x = (1:10)./2;
V = 1:2:19;
plot(x, V, '-o') % X coordinates 0.5, 1.0, 1.5, etc.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by