plot differential equation (ODE)
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
please help me to plot this equation y=5*cos(sqrt(2)*x)
This is my plotting but it is not correct
x=0:1:20;
y=zeros(length(x));
for i=1:length(x)
    y(i)=5*cos(sqrt(2)*x(i));
end
figure,
plot(y(1:20));
댓글 수: 2
  Mukhtar Hussain
 2014년 1월 27일
				Try this if it works
x=0:0.01:20;
y=zeros(length(x));
for i=1:length(x)
    y(i)=5*cos(sqrt(2)*x(i));
end
figure;
plot(x,y);
답변 (1개)
  Azzi Abdelmalek
      
      
 2012년 12월 2일
        
      편집: Azzi Abdelmalek
      
      
 2012년 12월 2일
  
      It's not y=zeros(length(x)) but y=zeros(1,length(x));and dont use i ( reserved to complex numbers)
 x=0:1:20;
 y=zeros(1,length(x));
 for ii=1:length(x)
   y(ii)=5*cos(sqrt(2)*x(ii));
 end
 figure,
 plot(y);
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!