Conversion of C code to Matlab code
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have a code written by C , Can anyone write it in Matlab script form, Please ?
#include <stdio.h>
#include <stdlib.h>
int main()
{ float pr=0.734,n=1.413*pow(10,-5),ts=12,to,nu,re,h,q,v,l=10,w=5,k=0.02428;
for(v=2;v<=50;v+=2)
{ re=(v*(0.277778)*l)/n;
nu=((0.037*pow(re,0.8))-871)*pow(pr,0.333333);
h=(nu*k)/l;
printf("\n\n(velocity : %f(km/h) )\t",v);
printf(" (rynold : %f)\t",re);
printf("(nusselt : %f)\t",nu);
printf(" (h : %f(w/m^2*k))\n",h);
for(to=0;to<=10;to++)
{
if(ts>to)
q=h*(l*w)*(ts-to);
else q=h*(l*w)*(to-ts);
printf("\t\t\tthe heat loss from surface is : %f\n",q);
}
}
return 0;
}
0 commentaires
Réponse acceptée
Jan
le 16 Déc 2022
Modifié(e) : Jan
le 16 Déc 2022
pr = 0.734;
n = 1.413e-5;
ts = 12
l = 10;
w = 5;
k =0.02428;
for v = 2:2:50
re = (v * 0.277778 * l) / n;
nu = (0.037 * re^0.8 - 871) * pr^0.333333;
h = (nu*k) / l;
fprintf("\n\n(velocity : %f(km/h) )\t",v);
fprintf(" (rynold : %f)\t",re);
fprintf("(nusselt : %f)\t",nu);
fprintf(" (h : %f(w/m^2*k))\n",h);
for to = 0:10
if ts > to
q = h * l * w * (ts-to);
else
q = h * l * w * (to-ts);
end
fprintf("\t\t\tthe heat loss from surface is : %f\n", q);
end
end
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Coder dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!