Plotting a function with difference between 2 vectors?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Niklas Kurz
le 8 Mai 2021
Modifié(e) : Niklas Kurz
le 9 Mai 2021
I want to plot
where
is the magnitude of the distance between 2 vectors:
: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611590/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611575/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611580/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611585/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/611590/image.png)
If I would implement this idea in Matlab:
[r1,r2] = meshgrid(linspace(-1,1,100));
phi = 1./(r1-r2);
mesh(r1,r2,phi)
what's nor really any kind of potential. Instead
[r1,r2] = meshgrid(linspace(-1,1,100));
phi = 1./sqrt((r1.^2+r2.^2));
mesh(r1,r2,phi)
is drawing the shape I sougth. Where does this difference originate from?
0 commentaires
Réponse acceptée
Cris LaPierre
le 8 Mai 2021
Modifié(e) : Cris LaPierre
le 8 Mai 2021
The shape is caused by where you can divide by 0. The difference is that, in the first case, this occurs along the diagonal line r1-r2=0. In the second case, the only time you divide by 0 is when r1=r2=0, hence the peak at a single point, (0,0).
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!