How to use RBF neural network to solve the following problems?

10 views (last 30 days)
two question:
1. How to use the data with Curve Fitting in MATLAB, fitting it with cubic spline interpolation to add data points with limited test data? And draw the 3D surface after interpolation?
2. Although data points can be added after interpolation, it cannot describe all data points and data outside the test interval. For example, u=160, T? , so neural network fitting is adopted. What should be done if RBF neural network is used? (ay=1~8 is fixed,u can be increased to 200), is to find the interval ay=1~8,u=120-200 T?

Answers (1)

Purvaja
Purvaja on 13 Jun 2025
Hi there,
I understand that you want to fit limited data using cubic spline interpolation in MATLAB and then generate a smooth 3D surface from the fitted data.
  1. Cubic Spline Interpolation and 3D Surface Plotting: To perform cubic spline interpolation on your data and create a 3D surface plot, you can use the csapifunction from the Curve Fitting Toolbox.
x = [40 60 80 100 120];
y = [1.0 2.5 4.5 6.5 8.0];
z = [...
1.69656 2.03469 2.28864 2.52846 2.53858;
2.24590 2.72092 3.04772 3.22486 3.41692;
...];
% Generate a cubic spline approximation surface
splineFunc = csapi({y, x}, z);
[xq, yq] = meshgrid(40:1:120, 1:0.1:8);
zq = fnval(splineFunc, {yq(:,1), xq(1,:)});
% Plot the surface
figure;
surf(xq, yq, zq);
xlabel('Speed (km/h)');
ylabel('Acceleration (m/s²)');
zlabel('Response Value');
title('3D Spline Surface using csapi');
shading interp;
colorbar;
2. RBF Neural Network Fitting: You can use MATLAB's Neural Network Toolbox to train an RBF network to predict the response for new values of speed and acceleration.
% Training inputs
u = [40 60 80 100 120]; % speed
ay = [1.0 2.5 4.5 6.5 8.0]; % acceleration
[U, AY] = meshgrid(u, ay);
inputs = [U(:)'; AY(:)'];
targets = [...
1.69656 2.03469 2.28864 2.52846 2.53858;
2.24590 2.72092 3.04772 3.22486 3.41692;
...];
targets = targets(:)';
% Train RBF network
net = newrb(inputs, targets, 0, 1, 100, 1);
% Define prediction range
[uq, ayq] = meshgrid(120:5:200, 1:1:8);
test_inputs = [uq(:)'; ayq(:)'];
% Predict using trained network
predicted_T = net(test_inputs);
predicted_T = reshape(predicted_T, size(uq));
% Plot the prediction surface
Refer to the following official MathWorks documentation to learn more about the methods used:
  1. Surf: https://www.mathworks.com/help/matlab/ref/surf.html
  2. Meshgrid: https://www.mathworks.com/help/matlab/ref/meshgrid.html
  3. Csapi: https://www.mathworks.com/help/curvefit/csapi.html
  4. Newrb: https://www.mathworks.com/help/deeplearning/ref/newrb.html
Hope this helps you!

Categories

Find more on Curve Fitting Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!