error when using stem()
이전 댓글 표시
I bought this product 2 days ago to do my homework. i tried doing the simplest stem function but i get an error no matter what i try..... why is stem bugged on my computer
x = 0:9;
y = sqrt(x);
figure(8);
stem(x,y,'m') % stem plot
axis([0 9 0 3])
set(gca,'FontSize',24)
set(gca,'XTick',0:9)
set(findobj(gcf,'LineWidth',0.5),'LineWidth',2)
saveas(8,'stem','png')
the error :
Error in Untitled2 (line 4)
stem(x,y,'m') % stem plot
댓글 수: 6
Star Strider
2018년 9월 5일
Run the ver command in your Command Window.
Then click on Contact Us in the upper right corner of this page to ask a Technical Support question about your problem.
the cyclist
2018년 9월 5일
Your code works for me.
Is that that full text of the error message you get? If not, please post the full error message.
tzela yaish
2018년 9월 6일
Image Analyst
2018년 9월 6일
It is NOT. There is always an error message. It is never just a line number and the line of code. There is always an explanation.
Steven Lord
2018년 9월 6일
That's odd. Usually if a MathWorks function throws an error it will explain in more detail why it threw the error. Are you certain there's no other text displayed in red and/or orange when you ran that code?
Walter Roberson
2018년 9월 6일
What shows up when you command
which -all stem
답변 (1개)
Image Analyst
2018년 9월 5일
It worked fine for me. Here is the modern OOP way of programming it (you're using the old fashioned way):
x = 0 : 9;
y = sqrt(x);
hFig = figure;
stem(x, y, 'm', 'LineWidth', 2) % stem plot with line 2 pixels wide
grid on;
% Set up range for x and y axes.
xlim([0, 9]);
ylim([0, 3.5]);
xticks(0:9)
ax = gca;
ax.FontSize = 24 % Make axis labels big
% Thicken up the bounding box and grid lines.
ax.LineWidth = 4
% Save the figure as a PNG image.
fullFileName = fullfile(pwd, 'stem.png');
saveas(hFig, fullFileName)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!