MATLAB Answers

How send Matlab (.mat file) output to a webpage

3 views (last 30 days)
ally on 1 Jan 2013
We have a trained neural network mat file. Now, I want to display its output on the webpage. We use this command in the Matlab to retrieve the results: sim(net,[A;B;C])
I tried to use donetbuilder, but I could not make it with .mat file. It needs a .m file to attach to a class!?
Moreover, I could not find any related codes about deploying .mat files on the web in the Mathworks?
Thank you!

Answers (2)

Walter Roberson
Walter Roberson on 1 Jan 2013
Net-Builder cannot be used to package Simulink functions. You would need Simulink Coder, and I am not sure at the moment whether it would support the neural network functions.
ally on 4 Jan 2013
I included %#function. But I do not know what the problem is?
// MATLAB Code
%#function network
function T1 = celldata
T2 = sim(net,[W1;T1;RH1;S1]);
//// net variable is located inside SIMdata.mat file
// C# Code
// Class name: CellAppClass
// Add File: Mfunction.m
// Add Reference: SIMdata.mat
using System;
using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;
using Mfunction;
namespace MData
class CellApp
static void Main(string[] args)
MWCellArray cellout = null;
MWNumericArray output = null;
CellAppClass obj = new CellAppClass();
cellout = (MWCellArray)obj.Mfunction();
MWNumericArray W1 = (MWNumericArray)cellout[1];
MWNumericArray T1 = (MWNumericArray)cellout[1];
MWNumericArray RH1 = (MWNumericArray)cellout[1];
MWNumericArray S1 = (MWNumericArray)cellout[1];
Console.WriteLine("W1 is {0}", W1);
Console.WriteLine("T1 is {0}", T1);
Console.WriteLine("RH1 is {0}", RH1);
Console.WriteLine("S1 is {0}", S1);
catch (Exception)

Sign in to comment.

owr on 4 Jan 2013
Last I checked (2 years ago), you can compile a call to the Neural Network Toolbox "sim" function. You cant compile any type of training functions (train, adapt, etc.), but simulating a pre-trained network shouldnt be an issue.
Looking at your code snippet above, if I had to guess, I'd say you're running into a problem with your call to "load". The compiled function may not be running in the active directory where "SIMdata.mat" is located. Try using a full path just in case that is that is the issue? You cna always revise later once you have a solution working.
Also, I would try using the form of load that captures an output:
out = load('SIMdata.mat')
T2 = sim(,[W1;T1;RH1;S1]);
Ive run into issues in the past with this as the compiler doesnt know exactly which version of "sim" to include in the package without being able to sope the run time type of "net".
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by