can anybody convert MATLAB code to c code ? please help

조회 수: 9 (최근 30일)
Anushka vyas
Anushka vyas 2021년 12월 8일
댓글: Anushka vyas 2021년 12월 8일
close all;
clear all;
clc;
n=4;
w=3;
h=3;
x=linspace(0,w,n);
y=linspace(0,h,n);
T=zeros(n);
T(1,1:n)=100;
T(n,1:n)=20;
T(1:n,1)=30;
T(1:n,n)=40;
tol=1e-6;
error=1;
k=0
while error >tol
k=k+1
Told=T
for i = 2:n-1;
for j = 2:n-1;
T(i,j) = .25 * (T(i,j-1) + T(i-1,j) + T(i+1,j) + T(i,j+1));
end
end
error = max(max(abs(Told-T)));
end
subplot(3,1,1),contour(x,y,T),colormap
title('Temprature(Steady State)'),xlabel('x'),ylabel('y'),colorbar
subplot(3,1,2),pcolor(x,y,T),shading interp,
title('Temprature(Steady State)'),xlabel('x'),ylabel('y'),colorbar
subplot(3,1,3)
surf(T')
xlabel('x')
ylabel('y')
zlabel('z')
colorbar
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 12월 8일
If you need the graphics, then you are going to have to locate a graphics package that you can call from your C code, and write the program in terms of using that. For example you might use gnuplot() http://www.gnuplot.info/
Anushka vyas
Anushka vyas 2021년 12월 8일
okay thank u so much

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Object Containers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by