passing an array of structures to a function

7 Ansichten (letzte 30 Tage)
Mihály
Mihály am 8 Apr. 2011
Beantwortet: Taylor am 17 Jul. 2025
Dear Matlab-users, I wrote a function that expects a 2D array of structures as one of its inputs, and treats this variable as such in the function body:
function bma=dcm_bma(model_posteriors,models,nSamp)
But when I try to call the function by passing such a data structure to it, I get the error message:
models =
21x8 struct array with fields:
dcm_bma(posteriors,models,1000);
??? Undefined function or method 'dcm_bma' for input arguments of type 'struct'.
How could I specify that that's exactly what I try to define it for?
Thanks for your help, Mihály
  2 Kommentare
Patrick Kalita
Patrick Kalita am 8 Apr. 2011
When you get this error, are you sure that dcm_bma is on your path? What happens if you execute:
>> which dcm_bma
Jan
Jan am 8 Apr. 2011
@Patrick: This is a very likely reason. I'd vore it, if it is written as an answer.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Taylor
Taylor am 17 Jul. 2025
dcm_bma probably is not on your path
https://www.mathworks.com/help/matlab/ref/addpath.html

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by