TIME=1:1:100; Z = 1: 1: 100; [X,Y]=meshgrid(TIME,Z); P = 12242-28.649. * Cos (6.28. * TIME + 1.33. * Z) -1702.3. * Sin (6.28. * TIME + 1.33. * Z) -495.13. * Cos (12.57. * TIME + 2.67 * Z) + 986.71. * Sin (12.57. * TIME + 2.67. * Z) + 498.18. * Cos (18.85. * TIME + 4. * Z) -398.52. * Sin (18.85. * TIME + 4. * Z) -319.34 . * cos (25.13. * TIME + 5.33. * Z) + 165.06. * sin (25.13. * TIME + 5.33. * Z) + 213.61. * cos (31.42. * TIME + 6.67. * Z) -71.69. * sin (31.47. * TIME + 6.67. * Z) -151.29. * cos (37.7. * TIME + 8. * Z) + 29.867. * sin (37.7. * TIME + 8. * Z) + 112.34. * cos ( 43.98. * TIME + 9.33. * Z) -9.378. * Sin (43.98. * TIME + 9.33. * Z) -86.576. * Cos (50.266. * TIME + 10.667. * Z) -1.2438. * Sin (50.266. * TIME + 10.667. * Z); surf(Z,P,TIME) The error is always the same: ??? Error using ==> surf at 78 Z must be a matrix, not a scalar or vector. Error in ==> signal at 5 surf(Z,P,TIME)
Neeta Dsouza answered .
2025-11-20
The easiest way to do what you want is to convert P into an anonymous function and pass it the correct arguments:
TIME=1:1:100; Z = 1: 1: 100; [X,Y]=meshgrid(TIME,Z); P = @ (TIME, Z) 12242-28.649. * Cos (6.28. * TIME + 1.33. * Z) -1702.3. * Sin (6.28. * TIME + 1.33. * Z) -495.13. * Cos (12.57. * TIME + 2.67 * Z) + 986.71. * Sin (12.57. * TIME + 2.67. * Z) + 498.18. * Cos (18.85. * TIME + 4. * Z) -398.52. * Sin (18.85. * TIME + 4 . * Z) -319.34. * Cos (25.13. * TIME + 5.33. * Z) + 165.06. * Sin (25.13. * TIME + 5.33. * Z) + 213.61. * Cos (31.42. * TIME + 6.67. * Z) -71.69. * Sin (31.47. * TIME + 6.67. * Z) -151.29. * Cos (37.7. * TIME + 8. * Z) + 29.867. * Sin (37.7. * TIME + 8. * Z) + 112.34. * Cos (43.98. * TIME + 9.33. * Z) -9.378. * Sin (43.98. * TIME + 9.33. * Z) -86.576. * Cos (50.266. * TIME + 10.667. * Z) -1.2438 . * sin (50.266. * TIME + 10.667. * Z); Pmtx = P(X,Y); surfc (X, Y, Pmtx)