Problem with ploting involving function handle
    26 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hi all, I encounter the following error when I want to plot a function involving function handle with symsum, I cannot figure out the error. My code is as follows. In my matlab 2023b, I receive the following error:
Warning: Error updating FunctionLine.
 The following error was reported evaluating the function in FunctionLine update: Undefined function 'symsum' for input arguments of type 'double'.
 N= 600
  sym ii
  COMx_k = @(k) symsum(1.*exp(-2*pi*1i*(k/N)*ii), ii,1,N)
  %k=0:0.1:300
  fplot(COMx_k)
  xlabel('k')
  ylabel('COMx_k')
0 Commenti
Risposta accettata
Più risposte (1)
  Walter Roberson
      
      
 il 13 Ott 2024
         sym ii
That is equivalent to
 ans = sym('ii');
which creates the symbolic symbol ii but throws away the reference to the symbolic symbol.
What you probably wanted was
 N= 600
 syms ii
 COMx_k = @(k) symsum(1.*exp(-2*pi*1i*(k/N)*ii), ii,1,N)
 fplot(COMx_k)
 xlabel('k')
 ylabel('COMx_k')
However, this takes a fair amount of time to plot !!
1 Commento
  Walter Roberson
      
      
 il 13 Ott 2024
				@(k) symsum(1.*exp(-2*pi*1i*(k/N)*ii), ii,1,N)
That is complex-valued when k is not an integer, and is 0 when k is an integer.
Vedere anche
Categorie
				Scopri di più su Calculus in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






