How can I interpolate a multiinput-multioutput function in MATLAB based on scattered data?
    3 views (last 30 days)
  
       Show older comments
    
    MathWorks Support Team
    
 on 16 Dec 2020
  
    
    
    
    
    Answered: MathWorks Support Team
    
 on 16 Dec 2020
            Given is a matrix 'A' with size 'm' x 'n' which contains a set of scattered data. Integer 'n' can be split into 'n1' and 'n2', where 'n1' stands for the number of input variables and 'n2' stands for the output variables of a function f, such that '[y1, y2, ..., yn2] = f(x1, x2, ..., xn1)'. Then, integer 'm' stands for the number of provided pairs of tuples '(y1, y2, ..., yn2)' - '(x1, x2, ..., xn1)'. It is sought for a workflow that allows the intepolated output tuple '(yHat1, yHat2, ..., yHatn2)' of function 'f' on a new input tuple '(xHat1, xHat2, ...,xHatn1)'.
How can I interpolate a multiinput-multioutput function in MATLAB?
Accepted Answer
  MathWorks Support Team
    
 on 16 Dec 2020
        As of R2020b, there is no available method in MATLAB that allows the interpolation a multiinput-multioutput function based on scattered data. 'scatteredInterpolant' can only be used for up to 3 dimensions.
This workflow can be achieved by training a deep neural network on the provided pairs of tuples exploiting the 'featureInputLayer' for the input layer of the corresponding network. An example is provided in the following, that should serve as a demonstration and should be adjusted for a particular training task:
%% Number of input and output variables
numInput = n1;
numOutput = n2;
%% Definition of the training data
x = A(:, 1:numInput);
y = A(:, numInput + 1:end);
%% Definition of a sample layer architecture
layers = [ ...
  featureInputLayer(numInput, "Name", "myFeatureInputLayer")
  fullyConnectedLayer(8, "Name", "myFullyConnectedLayer1")
  tanhLayer("Name", "myTanhLayer")
  fullyConnectedLayer(numOutput, "Name", "myFullyConnectedLayer2")
  regressionLayer("Name", "myRegressionLayer")
];
%% Definition of sample training options
opts = trainingOptions('adam', ...
  'MaxEpochs', 1000, ...
  'InitialLearnRate', 0.01,...
  'Shuffle', 'every-epoch', ...
  'Plots', 'training-progress', ...
  'MiniBatchSize', 128, ...
  'Verbose', false);
%% Training of the network
[trainedNet, info] = trainNetwork(x, y, layers, opts);
%% Compute a predicted output tuple on a new input tuple
% Please replace 'xHat' with the input vector of the actual application case 
% in order to be able to run the following commands
% xHat = [xHat1 xHat2 ... xHatn1];
% yHat = predict(trainedNet, xHat)
0 Comments
More Answers (0)
See Also
Categories
				Find more on Get Started with Deep Learning 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!