Output simple function matlab

Fermé
Hello_sarra Messages postés 33 Date d'inscription samedi 22 décembre 2012 Statut Membre Dernière intervention 22 février 2014 - 19 mars 2013 à 08:47
Krys_06 Messages postés 22 Date d'inscription jeudi 7 mars 2013 Statut Membre Dernière intervention 29 mars 2013 - 20 mars 2013 à 11:09
function y=fcv(w,h,k,T)

if w>0
y= w.^2.*exp(h*w./(k*T))./(exp(h*w./(k*T))-1).^2; %% or w>0 only
else
y=0; %%% Quand w=0
end

le problem quand je prend w=[0,1,2,3,4]; et je tape dans windows Matlab
h=1; T=1; k=1;
y=fcv(w,h,k,T)

mais je nobtiens pas y l'output
A voir également:

1 réponse

Krys_06 Messages postés 22 Date d'inscription jeudi 7 mars 2013 Statut Membre Dernière intervention 29 mars 2013
Modifié par Krys_06 le 20/03/2013 à 11:10
Tu ne peux pas mélanger de la vectorisation avec un "if (w > 0)".
En revanche, tu peux faire quelque chose du style:

function y = fcv (w,h,k,T)
y = zeros(size(w));
y(w>0)= w(w>0).^2.*exp(h*w(w>0)./(k*T))./(exp(h*w(w>0)./(k*T))-1).^2;
end
0