surf function plotting temperature

4 views (last 30 days)
kileigh palmer
kileigh palmer on 7 Mar 2021
Answered: Star Strider on 7 Mar 2021
The question is: Use Matlab to plot the temperature distribution in the slab, T(x,y)using 50terms of the series solution. Use the “surfc” command to plot the distribution as a surface with a contour map underneath. If you were going to put up asafety barricade, where would you recommend putting it?
My already generated equation is the Cn I have in the code. For some reason nothing is plotting though, any help? My code is below:
clear;
clc;
L = 25; % in m
W = 100; % in m
k = 0.5; % in W/mK
qs = 20; % in W/m2
N = 50;
T = zeros(N);
for c = 1:N
Cn = ((2*qs*L)/(k*(3.14^2)))*(((-1)^(c+1)+1)/((c^2)*cosh(c*3.14*W/L)))*sin(c*3.14*W/L)*sinh(c*3.14*W/L)
surf(T, Cn)
xlabel('Temperature')
ylabel('Cn Values')
title('Temperature v Cn Values')
end

Answers (1)

Star Strider
Star Strider on 7 Mar 2021
The surf function requires either one or three arguments, if three the first two are either vectors or matrices of the independent variables and the third is a matrix of the dependent variable.
Also, in the ‘Cn’ calculation, it is necessaary to use element-wise operations. See the documentation section on Array vs. Matrix Operations for details on that.

Categories

Find more on Chemistry in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!