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

Antworten (1)

Star Strider
Star Strider am 13 Apr. 2026 um 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 Kommentare

T K
T K am 14 Apr. 2026 um 0:34
Bearbeitet: T K am 14 Apr. 2026 um 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 am 14 Apr. 2026 um 6:06
Bearbeitet: T K am 14 Apr. 2026 um 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 am 14 Apr. 2026 um 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 am 14 Apr. 2026 um 23:26
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Surfaces, Volumes, and Polygons finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 13 Apr. 2026 um 22:53

Kommentiert:

am 14 Apr. 2026 um 23:26

Community Treasure Hunt

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

Start Hunting!

Translated by