How to plot streamline of electric field from a column of data?

63 visualizaciones (últimos 30 días)
Bacha Munir
Bacha Munir el 10 de Sept. de 2025 a las 2:19
Comentada: Bacha Munir el 11 de Sept. de 2025 a las 6:33
Hi. I have a column of data and I want to plot it in MATLAB such that the color map show the intensity, as showin the attached figure?
  8 comentarios
Sam Chak
Sam Chak el 11 de Sept. de 2025 a las 5:52
@Bacha Munir, Thank you for your reply. But I do not quite understand. Let us ignore the NaN values and consider the 7th row as an example. The coordinates are (4.3975, 2.3949). Since the 3rd column is labeled "streamline," what does the value of "0" mean?
You may use the streamslice() function as suggested by @Chuguang Pan. However, to produce color-gradient streamlines that indicate the intensity of the electric field (as represented by the 4th column data), you might try the approach recommended by @Bjorn Gustavsson.
[x, y] = meshgrid(-1:1); % generate coordinates in the grid
u = 2.*x.*y; % horizontal component of the velocity vector
v = y.^2 - x.^2; % vertical component of the velocity vector
streamslice(x, y, u, v)
title('Magnetic Field')
axis square
axis([-1, 1, -1, 1])

Iniciar sesión para comentar.

Respuesta aceptada

Bjorn Gustavsson
Bjorn Gustavsson el 10 de Sept. de 2025 a las 7:59
So you have electrical potential along a nearly straight curve. If that's all you have it becomes tricky to understand what you're asking for, what do you mean by intensity? If you want to plot a coloured line there are a bunch of contributions on the file exchange:
cline (1), cline (a), cline (I) and at least one 3-D variant: plot 3-D-color-line.
You can either plot the potential along that curve directly:
cline(Epot(:,1),...
Epot(:,2),...
zeros(size(Epot(:,2))),...
Epot(:,4),turbo)
Where I've saved your columns of data into the variable Epot. My version of cline is a slightly modified version of one of those linked above.
...or if you want something like potential difference in between points:
cline(Epot(1:end-1,1),...
Epot(1:end-1,2),...
zeros(size(E_pot(1:end-1,2))),...
Epot(1:end-1,4),turbo)
You would have to check the input arguments to the cline-function you decide to use.
HTH

Más respuestas (0)

Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by