Neural networks in MATLAB require that the input data is formatted correctly, often as a column vector with a number of rows equal to the number of input features the network expects.
Here's what you need to check and potentially correct:
- Input Size: Ensure that the number of elements in inputData matches the number of input neurons in the network. If the network was trained with 15 features, then inputData must be an array of 15 elements.
- Input Shape: Neural networks in MATLAB typically expect inputs to be column vectors where each column is a sample and each row is a feature. If you are providing a single sample (as in your case), your input should be a column vector of size [net.inputs{1}.size x 1].
Here's how you can modify your code to ensure the input is a column vector:
function outputPower = predictPVOutput(inputData)
inputData = inputData(:);
outputPower = net(inputData);
Then, when you call predictPVOutput, make sure inputData is arranged as a column vector:
inputData = [4; 40; 277; 7; 0; 0; 0.16; -30; 3.2; 0; 0; 96.2; 1020; 271; 4];
output = predictPVOutput(inputData);
If your network expects data normalized in a certain way (for example, between -1 and 1, or 0 and 1), you must also preprocess your input data in the same way it was preprocessed during training before passing it to the network.
Lastly, if the network was trained with batch data or time-series data, the input data might need to be formatted accordingly. Check the training code to confirm how the input data was shaped. If you can't resolve the issue with these suggestions, you might need to look back at how the network was trained and how the training data was formatted.
---------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
Feel free to contact me.