Borrar filtros
Borrar filtros

what this matlab syntax var1= input.var2 corresponds to ?

8 visualizaciones (últimos 30 días)
wejden hammami
wejden hammami el 29 de Mayo de 2020
Editada: Brent Kostich el 29 de Mayo de 2020
Hello, i'm beginner in matlab and i'm asking for help, can someone tell me the signification of this matlab syntax ?
function [output1, output2] = BagOfWords(input, mode, geneIndex, dataForCurrentGene)
switch mode
case 'init'
data = input.data;
nGenesOverall = input.nGenes;
nFeatures = input.nFeatures;
maxNumberOfComponents = input.maxNumberOfComponents;
sparseMatrix = zeros(nGenesOverall,nFeatures);
sparseVector = false(1,nGenesOverall);
% Define the cluster structure
clusterStruct(1,maxNumberOfComponents) = struct(...
'nFeatures', [], ...
'nGenesOverall', [], ...
'beta', [], ...
'sumBeta',[],...
'nGenes', [], ...
'logMarginalLikelihood', [],...
'dataCounts', [], ...
'logicalGeneIDs', [], ...
'N', []);
I didn't understand if input is a simple argument of the function BagOfWords or it refers to requesting user input? Else, what do these instructions (example: nGenesOverall = input.nGenes ) mean ?

Respuesta aceptada

Brent Kostich
Brent Kostich el 29 de Mayo de 2020
Editada: Brent Kostich el 29 de Mayo de 2020
Regarding this segment of code
BagOfWords(input, mode, geneIndex, dataForCurrentGene)
Everything inside the parenthesis is an input argument to the function BagOfWords. In the case of this funtion, input is a structure array. The dot notation references data in different fields of that array. For example:
input.nGenes follows the form struct.field
Since you are new to MATLAB, the above example is just a primer. I would encouage you to read through some of the documentation or look into Onramp to learn more about the syntax.

Más respuestas (1)

Fangjun Jiang
Fangjun Jiang el 29 de Mayo de 2020
It is called struct. Follow the link to see the document and you can try youself.
input.var2=2;
input.var3=rand(3);
MyVar=input.var3

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by