Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Free space loss 3D Plot
#1
Hello everyone
I have the function:

#free space loss calculation
def fspl(d, f): 
    x = 4*math.pi
    ls = 3*10**8
    result = 20*math.log10(d)+20*math.log10(f)+20*math.log10(x/ls)
    return result
and two of the axis:
f = np.linspace(0,10000)
d = np.linspace(0,1000000)

How can I plot this into a 3D Surface with the axis frequency (y), distance (x) and free space loss (z)?

Thanks a lot for your help already in advance!
Reply
#2
I proceeded a bit and got the following code but there is still an error 'only size-1 arrays can be converted to Python scalars'. What's wrong with my code?

import math
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
ax = plt.axes(projection='3d')

def function(d, f):
    x = 4*math.pi
    ls = 3*10**8
    test = 20*math.log10(d)+20*math.log10(f)+20*math.log10(x/ls)
    return test

x = np.linspace(0,10, 100)
y = np.linspace(0,10, 100)

X,Y = np.meshgrid(x,y)
Z = function(X,Y)

ax.plot_surface(X,Y,Z)
plt.show()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Win or Loss Prediction ksasi2k3 4 380 Apr-25-2024, 01:46 PM
Last Post: ksasi2k3
  How to plot intraday data of several days in one plot mistermister 3 2,990 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  from global space to local space Skaperen 4 2,383 Sep-08-2020, 04:59 PM
Last Post: Skaperen
  How to plot vertically stacked plot with same x-axis and SriMekala 0 1,968 Jun-12-2019, 03:31 PM
Last Post: SriMekala

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020