Conversion of C code to Matlab code

14 ビュー (過去 30 日間)
Karim Ayman
Karim Ayman 2022 年 12 月 16 日
コメント済み: Jan 2022 年 12 月 16 日
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
  2 件のコメント
Karim Ayman
Karim Ayman 2022 年 12 月 16 日
Thanks a lot, my friend
Jan
Jan 2022 年 12 月 16 日
You are welcome. Do you see, that this was easy?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by