Trying to get this code to work but I am getting this error code (Error using plot A numeric or double convertible argument is expected), ( Error in Lab6 (line 8) plot(n,H,'r')
조회 수: 2 (최근 30일)
이전 댓글 표시
%Harmonic function for H(n)
title('Harmonic Function')
xlabel('values of n 1<=n<=100')
ylabel('Harmonic Function H(n)')
for n = 1:100
syms H(n)
H(n) = harmonic(n);
plot(n,H,'r')
end
%Harmonic function for ln n
title('Harmonic Function for log(n)')
xlabel('values of n')
ylabel('Harmonic Function log(n)')
for n = 1:100
syms f(n)
f(n) = log(n);
y = harmonic(f);
plot(n,y,'--','k')
end
%Harmonic function for 1+ln n
title('Harmonic Function')
xlabel('values of n')
ylabel('Harmonic function 1+log(n)')
for n = 1:100
syms f(n)
f(n) = 1+log(n);
y = harmonic(f);
plot(n,y,'--','k')
end
댓글 수: 1
답변 (1개)
Walter Roberson
2016년 2월 18일
MATLAB cannot plot symbolic formula.
H = zeros(1,100);
yL = zeros(1,100);
yL1 = zeros(1,100);
N = 1 : 100;
for n = N
H(n) = double( harmonic(sym(n)) );
yL(n) = double( harmonic( log(sym(n)) ) );
yL1(n) = double( harmonic( 1 + log(sym(n)) ) );
end
plot(N, H, 'r', N, yL, '--k', N, yL1, ':g');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!