how can i plot func between the interval below , i don't have an image of the function anymore but the exact way the function was given was sin(3*x^2) , i'm not receiving any errors just a blank figure
x=-23:.1:23;
func=sin(3*x.^2);
plot(x,func);grid on;axis tight;

댓글 수: 1

Bob Thompson
Bob Thompson 2021년 1월 18일
The code you posted worked fine for me. Is there some additional code you have with this? Perhaps the issues lies there.

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

 채택된 답변

madhan ravi
madhan ravi 2021년 1월 18일

1 개 추천

shg % at the end perhaps?

댓글 수: 5

Opariuc Andrei
Opariuc Andrei 2021년 1월 18일
%% function s=sin(3*x^2)
x=-23:.1:23;
func=sin(3*x.^2);
plot(x,func);grid on;axis tight;
subplot(2,2,1);title('func=sin(3*x^2)')
%% circle
t=0:.01:2*pi; x=3*cos(t); y=3*sin(t);
subplot(2,2,2);plot(x,y);grid on; title('r=3');hold on;
%% cone
R =10; r=5;H =5;
N = 500;
[x, y, z] = cylinder([r R], N);
subplot(2, 2 ,3)
meshc(x, y, H*z);title('con mesh');xlabel('x');ylabel('y');zlabel('z/H');
%% triangle
t=[-30*pi/180 pi/2 210*pi/180 -30*pi/180];
xt=20/sqrt(3)*cos(t); yt=4/sqrt(3)*sin(t);
subplot(2,2,4);plot(xt,yt);grid on;axis tight;title(' triunghi cu l=20');
this is the entire plotting requirement , 3/4 work fine but the function isn't displaying anything
You need to switch the order of your subplot call out, and the plot of func.
subplot(2,2,1);title('func=sin(3*x^2)')
plot(x,func);grid on;axis tight;
The way you have it, it's creating the plot first in Fig(1), then overwriting with the 2x2 subplot.
Opariuc Andrei
Opariuc Andrei 2021년 1월 18일
also how do i use shg ? i use it in command window ?
Opariuc Andrei
Opariuc Andrei 2021년 1월 18일
편집: Opariuc Andrei 2021년 1월 18일
ok so i did it without the subplot and it works ,but the figure is supposed to be there in the top left corner , it's a requirement , i tweaked it's position to (2,2,2/3/4) and still no display , how can i make it function ?
Opariuc Andrei
Opariuc Andrei 2021년 1월 19일
ok so i moved the subplot 2 lines up and put it before the plot and got it to work
x=-23:.1:23;
func=sin(3*x.^2);
subplot(2,2,1);
plot(x,func);grid on;axis tight;
title('func=sin(3*x^2)');

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2021년 1월 18일

댓글:

2021년 1월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by