I am trying to plot a series, with multiple variables.

9 views (last 30 days)
I am trying to plot this function for T:
T_1, H and L are all set values.
T_1=100 degrees C
H=2m
L=1m
I want the first 20 iterations of n
In this case X will range from 0-L and Y from 0-H.
I tried using a linspace to get dx and dy values of 0.1 but I wasn't able to get the code to plot.
I was able to get values in a table but no luck plotting. Here is my code:
clc;
% Define parameters
T_sub_1 = 100;
H = 2;
L=1;
% Create meshgrid
x=linspace(0,2,20);
y=linspace(0,4,40);
T = symsum((1 - (-1)^n) * sinh(n * pi * (H - y) / L) ./ (n * pi * sinh(n * pi * H / L)) * sin(n * pi * x / L),n,1,20);
plot(T)

Answers (2)

VBBV
VBBV on 20 Nov 2023
clc;
% Define parameters
T_sub_1 = 100;
H = 2;
L=1;
syms n
% Create meshgrid
x=linspace(0,2,20);
y=linspace(0,4,20);
T = T_sub_1*2*symsum( ((1- (-1)^n) * sinh(n * pi * (H - y) / L) )./ ((n * pi) * sinh(n * pi * H / L)).* sin(n * pi * x / L),n,1,20);
plot(T)

Dyuman Joshi
Dyuman Joshi on 20 Nov 2023
Firstly - To use "n" as a symbolic variable, you will have to define it as a symbolic variable.
Secondly, you have mentioned to define a meshgrid, but have not done so in code. So I assume (from that comment) that you want to plot a surface plot, not a line plot.
% Define parameters
T_sub_1 = 100;
H = 2;
L=1;
%% Define n as a symbolic variables
syms n
% Create meshgrid
x=linspace(0,2,20);
y=linspace(0,4,20).';
T = T_sub_1*2*symsum( ((1- (-1)^n) * sinh(n * pi * (H - y) / L) )/ ((n * pi) * sinh(n * pi * H / L))* sin(n * pi * x / L),n,1,20);
surf(double(T))
shading interp

Products

Community Treasure Hunt

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

Start Hunting!