Effacer les filtres
Effacer les filtres

Imperfect Plot

1 vue (au cours des 30 derniers jours)
Adi Mico
Adi Mico le 27 Juil 2011
I have a problem for plotting so it can make a squarewaveform.
here is my code
x=0:5:5000;
a='q';
bitk = reshape(dec2bin(double(a),8).' - '0', 1, []);
stairs(handles.axes1,x(1:length(bitk)),bitk(1:length(bitk)));
xlim(handles.axes1,[0 50]);
ylim(handles.axes1,[-1 2]);
the result is the graph isn't a squarewaveform. but the plot stairs is cut at bit 8. how can I fix this problem so at bit 8 make a squarewave and the rest of plot is 0?

Réponses (1)

Andreas Goser
Andreas Goser le 27 Juil 2011
When I remove 'handles.axes1' from your code and execute it, I see a figure with xlimits 0:35 and ylimits 0:1. This is exactly what is represented by the data x and bitk. I do not understand "but the plot stairs is cut at bit 8".
You may look for the AXIS command?
  2 commentaires
Adi Mico
Adi Mico le 27 Juil 2011
I've already made the GUI with handles.axes1 as my axes to view the plot. What become my problem is that the plot only plot up to x=35. I want that the last bit which the plot at x=35 as a squarewaveform.
Mr.Roberson from the other question of mine has solved this so my code become
x=0:5:5000;
a='q';
bitk = reshape(dec2bin(double(a),8).' - '0', 1, []);
if bitk(end) ~= 0
bitk(end+1) = 0;
end
stairs(handles.axes1,x(1:length(bitk)),bitk(1:length(bitk)));
xlim(handles.axes1,[0 50]);
ylim(handles.axes1,[-1 2]);
But, I want the rest of plot is 0 so it can show like a scope that view the squarewave.
Andreas Goser
Andreas Goser le 27 Juil 2011
In this case, I do not see alternatives to modify the data. PLOT, STAIRS etc. just display the data they have.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by