- In your code the output arguments are assigned within the if condition
- There is a possibility for your input data may not satisfies the if condition
- In such situation there is no arguments returned from the function
- You can avoid this error by defining the state of [t,X] using a else
Output argument "t" (and maybe others) not assigned during call to "Sum_Cosinefunction".
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi there,
So I'm working on a function that gives the output for a sum of cosines. But when I try to call the function, I get the error Output argument "t" (and maybe others) not assigned during call to "Sum_Cosinefunction". But I've looked over it quite a few times, but I seem to be missing something. Any thoughts? function [t,X] = Sum_Cosine(N,A,f,phi,B,Start,End,fs)
if (N < 0 ) disp('The number of sinusoids must be positive'); end
if ~all(isreal(A)) ~all(A>0) error('Amplitude must be real and postive elements'); end if ~all(isreal(B)) error('B must be real and postive elements'); end
if ~all(isreal(f)) error('f must be real and postive elements'); end
if ~all(isreal(phi)) error('Phi must be real and postive elements'); end
if (isreal(Start) == 0) disp('Starting and Ending time signals must be real'); end if(End < Start) disp('End time must be bigger than start time'); if (fs < (2*f)) disp('Sampling frequency must be greater than double the amount of frequency of the sinusoid'); end
t = linspace(Start,End,fs);
X = 0;
for i=1:N X = X + A(i)*cos(2*pi*f(i)*t + phi(i)) + B(i); end
end
this is my function call: Sum_Cosinefunction(1,5,10,3.14159,2,0,10,20);
댓글 수: 0
답변 (1개)
Stalin Samuel
2016년 3월 3일
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!