Conversion of C code to Matlab code

18 visualizaciones (últimos 30 días)
Karim Ayman
Karim Ayman el 16 de Dic. de 2022
Comentada: Jan el 16 de Dic. de 2022
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;
}

Respuesta aceptada

Jan
Jan el 16 de Dic. de 2022
Editada: Jan el 16 de Dic. de 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 comentarios
Karim Ayman
Karim Ayman el 16 de Dic. de 2022
Thanks a lot, my friend
Jan
Jan el 16 de Dic. de 2022
You are welcome. Do you see, that this was easy?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by