how to plot all zeros on xaxis?
古いコメントを表示
Hello,
I have the following code:
figure; plot(x_mm, adcValues)
Where the values look like:
adcValues x_mm
_________ _____
0.041117 -0.9
0.034457 -0.45
0 0
0 0
0 0
0 0
0 0
0 0
0.023807 0.45
0.030902 0.9
0.032225 1.35
and the plot looks like:

where you can see that the 6 zeros are being collapsed into one zero.
I instead want something like the red line where you are getting a step function at the first adcvalue that is not at zero:

Where the zeros are not all collapsed but instead visualized on the plot.
Thanks so much.
採用された回答
その他の回答 (1 件)
This data is not the same as what your plot shows. Looks like maybe you left out some points at the beginning and the end of the data.
Nevertheless, note that all six of the adcValues are located at x_mm location equal to zero. So the middle of the plot does reflect this data correctly.
data = ...
[ 0.041117 -0.9
0.034457 -0.45
0 0
0 0
0 0
0 0
0 0
0 0
0.023807 0.45
0.030902 0.9
0.032225 1.35 ];
If you want the plot to be flat at zero between -0.45 and 0.45, you need to provide x_mm data at those points. Perhaps this will do what you want.
adcValues = data(:,1);
x_mm = data(:,2);
x_mm(3) = x_mm(2); % add a zero adcValue at -0.45
x_mm(8) = x_mm(9); % add a zero adcValue at +0.45
plot(x_mm, adcValues, 'o-')
grid on
カテゴリ
ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


