Why the myfunction return zero elements?
Mostrar comentarios más antiguos
Hi all; I have a function which should return a R_gradient matrix. I identify its elements but when I call myfunction it returns zero elements. I checked the passing parameter kc there is nothing wrong with it and the values of the elements are calculated correctly when i calculated them separately (i.e. Rg22,....,Rg55). can any one explain what wrong with myfunction. Regards
function R_gradient = myfunction(kc)
r1 = 1e+5;
r2 = 0.5;
q = 1e-5;
ks = kc(1);
cs = kc(2);
param.ms = 325;
param.mus = 65;
param.kus = 232.5e3;
param.ct = 0 ;
Rg22=r2*(cs/param.ms)^2;
Rg23=-r2*(cs/param.ms)*(ks/param.ms);
Rg24=-r2*(cs/param.ms)^2;
Rg25=r2*cs/(param.ms^2);
Rg32=-r2*(cs/param.ms)*(ks/param.ms);
Rg33=r2*(ks/param.ms)^2;
Rg34=r2*(cs/param.ms)*(ks/param.ms);
Rg35=-r2*ks/(param.ms^2);
Rg42=-r2*(cs/param.ms)^2;
Rg43=r2*(cs/param.ms)*(ks/param.ms);
Rg44=r2*(cs/param.ms)^2;
Rg45=-r2*cs/(param.ms^2);
Rg52=r2*cs/(param.ms^2);
Rg53=-r2*ks/(param.ms^2);
Rg54=-r2*cs/(param.ms^2);
Rg55=q+r2/(param.ms^2);
R_gradient = [
r1 0 0 0 0;...
0 Rg22 Rg23 Rg24 Rg25;...
0 Rg32 Rg33 Rg34 Rg35;...
0 Rg42 Rg43 Rg44 Rg45;...
0 Rg52 Rg53 Rg54 Rg55];
end
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 17 de Jul. de 2016
If you getting out a matrix in which all except one entry are 0, then you need to give the command
format long g
and then look at the outputs again.
1 comentario
Muna Shehan
el 18 de Jul. de 2016
Categorías
Más información sobre Model Building and Assessment 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!