How to write this script in complex conjugate, it should have real and imaginary values
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Balaji Ramdas
 il 28 Nov 2021
  
    
    
    
    
    Risposto: Walter Roberson
      
      
 il 28 Nov 2021
            Results should have real and imaginary part in the form of (a+bi)
% Initilization 
r1source = zeros(length(y),length(x),length(z)) ; 
r2source = zeros(length(y),length(x),length(z)) ; 
r3source = zeros(length(y),length(x),length(z)) ; 
for m=1:length(y)
    for n=1:length(x)
        for o=1:length(z) 
            r1source(m,n,o)=sqrt((x(n)-x1)^2+(y(m)-y1)^2+(z(o)-z1)^2);
            r2source(m,n,o)=sqrt((x(n)-x2)^2+(y(m)-y2)^2+(z(o)-z2)^2);
            r3source(m,n,o)=sqrt((x(n)-x3)^2+(y(m)-y3)^2+(z(o)-z3)^2);
        end
    end
end
4 Commenti
  Walter Roberson
      
      
 il 28 Nov 2021
				            r1source(m,n,o)=sqrt((x(n)-x1)^2+(y(m)-y1)^2+(z(o)-z1)^2);
if x and x1 and y and y1 and z and z1 are all real-valued, then (x(n)-x1) and (y(m)-y1) and (z(o)-z1) will be real-valued, and the square of a real quantity is never negative, so the sum of squares would never be negative, so r1source would never be complex-valued.
For r1source to be complex-valued, at least one of the quantities would have to be complex-valued. If some of the quantities are real-valued but others are purely imaginary, then although the squares of the purely imaginary components would be negative, they might not be negative enough to balance the other parts, so you could end up with sqrt() of a positive number.
Risposta accettata
  Walter Roberson
      
      
 il 28 Nov 2021
        r1source = sqrt( (reshape(y,[],1)-y1).^2) + (reshape(x,1,[])-x1).^2 + (reshape(z,1,1,[])-z1).^2 );
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Image Filtering and Enhancement 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!


