Plot 2D electric field strength over distance (finite difference method)

조회 수: 2 (최근 30일)
Even Nøtland Giske
Even Nøtland Giske 2021년 2월 24일
답변: Jaynik 2024년 6월 24일
Hello.
I am trying to 2D plot the electric field strength in kV/m over distance, like the figure below.
How do I do this?
My workspace is below, voltages are in a 181x301 matrix.

답변 (1개)

Jaynik
Jaynik 2024년 6월 24일
Hi Even,
The electric field strength can be approximated by the gradient of the voltage with respect to distance. Here is a sample code to plot the data:
% Calculate the electric field strength (V/km)
% Assuming the voltageMatrix rows represent different distances
% and columns represent different measurements at those distances
electricFieldStrength = diff(voltageMatrix, 1, 2) ./ diff(distance);
% Adjust the distance array to match the size of electricFieldStrength
distanceMidPoints = (distance(1:end-1) + distance(2:end)) / 2;
% Plotting
figure;
plot(distanceMidPoints, electricFieldStrength);
xlabel('Distance (km)');
ylabel('Electric Field Strength (V/km)');
title('Electric Field Strength vs. Distance');
grid on;
  • The diff function computes the difference between adjacent elements. Here, it is used to approximate the gradient of the voltage with respect to distance.
  • The result is divided by the distance difference to get the electric field strength in V/km.
  • distanceMidPoints is calculated to align the x-axis values with the midpoints of the original distance intervals.
Please share more information regarding the data so that I can provide a more detailed answer.
Hope this helps!

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by