Conversion of C code to Matlab code

15 次查看(过去 30 天)
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;
}

采纳的回答

Jan
Jan 2022-12-16
编辑:Jan 2022-12-16
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by