简体   繁体   中英

How to use Real(); Complex(); functions to define a complex number in Matlab?

I am from the simple numbers world of audio and i am finding complex number errors in Matlab coder compilation:

The left-hand side has been constrained to be non-complex, but the right-hand side is complex. To correct this problem, make the right-hand side real using the function REAL, or change the initial assignment to the left-hand side variable to be a complex value using the COMPLEX function.

How do i use real function in this scenario?

tfr= zeros (N,tcol) ;  
for icol=1:tcol,
tfr(1,icol)= sum(g2 .* x(ti-points,1) .* conj(x(ti-points,xcol))); % error here

change the initial assignment to the left-hand side variable to be a complex value using the COMPLEX function.

Thus is exactly what you have to do.

tfr= complex(zeros (N,tcol) ) ;  

You must tell the coder to allocate a variable with sufficient space for a complex variable.

This has taken care of it for the moment:

changing initial array statement:

carr= zeros (N,tcol) ;  
tfr = complex(carr,0);

there are probably better answers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM