Struct contents reference from a non-struct array object
Mostrar comentarios más antiguos
hello
I am new to Matlab and I am trying to minimize the following function with fmincon:
function [ CRRA ] = CRRA(x)
tur = load('tur.mat');
wei = load('wei.mat');
ret = tur.tur *x';
first = 1 + ret;
util = ((first.^(-85))/(-85));
wut = wei. * util;
CRRA = -mean(wut);
end
tur is a 140x500 matrix, x is what I am looking for, i.e. a 1x500 matrix, and wei is a 140x1 matrix. The problem is the line
wut = wei. * util
where I want to multiply wei with util element by element. I get the message:
Struct contents reference from a non-struct array object
with reference to this line. I also tried wut = times (wei, util) but obviously didn't work.
When I copy wut = wei. * util; and paste it in the command editor it calculates wut correctly. I would really appreciate any help.
Thank you
Respuesta aceptada
Más respuestas (1)
Matt J
el 12 de Oct. de 2020
0 votos
I think you just have to get rid of the extra whitespace between . and *
3 comentarios
K Kassimatis
el 12 de Oct. de 2020
Use
>> dbstop if error
to pause execution where the error occurs and see what types of variables are being multiplied.
K Kassimatis
el 12 de Oct. de 2020
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!