Neural Network Toolbox for Curve and Surface Fitting

Version 1.2.8 (1.99 MB) by S0852306
N-Dimensional Curve and Surface Fitting and Nonlinear Regression Toolbox
629 Downloads
Updated 24 Feb 2026

View License

Neural Network Toolbox for N-Dimensional Curve and Surface Fitting
Multivariable Nonlinear Regression and Function Approximation Framework
Core Function
NN = NeuralFit(x, y, [N, M]);
Where:
  • x is N × D (input dimension × number of samples)
  • y is M × D (output dimension × number of samples)
  • [N, M] defines input/output dimension
Key Features
  • Fully customizable network architecture for enhanced modeling flexibility and fitting performance.
  • Arbitrary-dimensional mapping:
  • Lightweight MATLAB implementation.(no external dependencies)
Quick Example — 2D Nonlinear Surface Fitting
clear; clc; close all;
x = linspace(-2, 2, 20); y = x;
[X, Y] = meshgrid(x, y); U = X.^2 + Y.^2; Z = exp(-0.5*U).*cos(2*U);
data = [X(:), Y(:)].'; label = Z(:).';
NN = NeuralFit(data, label, [2, 1]);
Prediction = NN.Evaluate(data);
PerformanceMetric = NN.Report;
figure();
surf(X, Y, Z); hold on; scatter3(data(1, :), data(2, :), Prediction)
Installation
  1. Navigate to the folder
  2. In the MATLAB Command Window, run:
setupNeuralNetPath
Basic Network and Solver Setup
Below is a minimal example showing how to manually configure the network architecture and optimization process.
data = linspace(0,2*pi,1000); label = (data).*sin(data) + cos(3*data);
LayerStruct = [1, 7, 7, 7, 1];
NN = Initialization(LayerStruct);
option.MaxIteration = 600;
NN = OptimizationSolver(data, label, NN, option);
Prediction = NN.Evaluate(data);
Two ready-to-use workflow templates are included:
SimplifiedWorkflow.m
A minimal interface for quick nonlinear regression with default settings.
Recommended for rapid experimentation and general use.
CustomizableWorkflow.m
Provides full control over network architecture, solver selection, and training parameters.
Intended for advanced modeling and high-precision applications.
Training Tips
  • Normalize inputs for better convergence
  • Use LBFGS/BFGS refinement for high precision
Available Optimization Solvers
'SGD'
'SGDM'
'RMSprop'
'ADAM'
'AdamW'
'BFGS'
'LBFGS'
For mathematical details about deep neural nets, see MathModel.mlx.
References
  • Nocedal & Wright — Numerical Optimization
  • Goldfarb et al. — Practical Quasi-Newton Methods
  • Yi Ren et al. — Kronecker-Factored Quasi-Newton Methods

Cite As

S0852306 (2026). Neural Network Toolbox for Curve and Surface Fitting (https://www.mathworks.com/matlabcentral/fileexchange/129589-neural-network-toolbox-for-curve-and-surface-fitting), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.2.8

- fix path issue

1.2.7

Codebase refactored for improved structure and maintainability
Added L-BFGS solver for memory-efficient quasi-Newton optimization
Introduced a wavelet activation function for periodic data modeling
Fixed bug related to custom activation function con

1.2.6

Reorganized

1.2.5

Update instructions.

1.2.4

Fit data with a single line of code.

1.2.3

minor update

1.2.2

Add a weighted least-squares option, see "WeightedListSquare.m".

1.2.1

Explain the mathematical model of neural nets using a live script.

1.2.0

Solver update: AdamW, avoiding overfitting by weight decay.

1.1.9

Add MAE cost for robust surface fitting.

1.1.8

Minor update.

1.1.7

Solver minor update

1.1.6

1. Handwritten digit recognition (MNIST).
2. Bug fixed.

1.1.5

1. Add cross-entropy cost for classification problems.
2. ReLU bug fixed

1.1.4

1. Add Cross-Entropy Cost for Classification Task.
2. ReLU bug fixed.

1.1.3

New Solver 'RMSprop'

1.1.2

Minor Bug Fixed.
(Previous Version) There was an error in calculating the gradient for the bias in the last layer, but strangely, it didn't have a significant impact on the training results.

1.1.1

Solver Improvement.

1.1.0

Improve efficiency.
Bug fixed.

1.0.9

bug fixed

1.0.8

autoscaling
automatic derivatie

1.0.7

Added Autoscaling Function
Automatic Derivate Calculation (for x, i.e. input, not parameters of NN)
Simplified Command

1.0.6

Added autoscaling capability.
Added automatic derivate function for x.

1.0.5

guided

1.0.3

user guide

1.0.2

User Guide

1.0.1

Added User Guide. ("Guide.mlx")

1.0.0