Please help me to run this simple relation

I want to draw relation between T ( y-axis) and x ( x-axis) with change parameter B1.
Constant:
B2=0.01;B4=0.1;
vector
Parameter
B1=0.1:0.1:0.5

Respuestas (1)

Star Strider
Star Strider el 13 de Abr. de 2026 a las 23:36
Probably the easiest way to do this is with a surf plot. Here, I combined it with a contour plot as well, using the surfc function.
Try something like this --
B2 = 0.01;
B4 = 0.1;
B1=0.1:0.1:0.5;
x = 0:0.01:1;
[xm,B1m] = ndgrid(x,B1);
T = (B1m-B2)./(3*B4) .* (1 + exp(xm));
figure
surfc(xm, B1m, T)
colormap(turbo)
colorbar
xlabel('x')
ylabel('B1')
zlabel('T')
.

5 comentarios

T K
T K el 14 de Abr. de 2026 a las 0:34
Editada: T K el 14 de Abr. de 2026 a las 0:42
I want to draw in 2 Dimension X-axis is X Y-axis is T Parameter is B1
I missed the fact that the first term was negated earlier. Corrected here.
Here you go ---
B2 = 0.01;
B4 = 0.1;
B1=0.1:0.1:0.5;
x = 0:0.01:1;
[xm,B1m] = ndgrid(x,B1);
T = (B1m-B2)./(3*B4) .* (exp(xm) - 1);
figure
plot(x, T)
grid
xlabel('x')
ylabel('T')
title('$T(x,B1) = \frac{(B1-B2)}{3B4}(e^x-1)$', Interpreter='LaTeX')
legend(compose('B1 = %.1f', B1), Location='best')
figure
surfc(xm, B1m, T)
colormap(turbo)
colorbar
xlabel('x')
ylabel('B1')
zlabel('T')
title('$T(x,B1) = \frac{(B1-B2)}{3B4}(e^x-1)$', Interpreter='LaTeX')
.
T K
T K el 14 de Abr. de 2026 a las 6:06
Editada: T K el 14 de Abr. de 2026 a las 6:07
Oh,thanks alot professor Star. Finally, what is the importance of [xm,B1m] = ndgrid(x,B1) in this code ??
Star Strider
Star Strider el 14 de Abr. de 2026 a las 10:27
My pleasure!
That assignment creates matrices of the same sizes for 'x' and 'B1', creating 'xm' (x matrix) and 'B1m' (B1 matrix). The matrices are important because they make the calculations easier, eliminating explicit loops that would otherwise be required.
The 'T' calculation
T = (B1m-B2)./(3*B4) .* (exp(xm) - 1);
then uses them to produce its own matrix, with dimensions matching the original matrices. That makes the plotting easier.
The 'dot operators force array (element-wise) division (./) and multiplication (.*) rather than matrix division and multiplication.
.
Star Strider
Star Strider el 14 de Abr. de 2026 a las 23:26
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Categorías

Más información sobre Surfaces, Volumes, and Polygons en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Abr. de 2026 a las 22:53

Comentada:

el 14 de Abr. de 2026 a las 23:26

Community Treasure Hunt

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

Start Hunting!

Translated by