Please help me to run this simple relation
Afficher commentaires plus anciens
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
Réponses (1)
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 commentaires
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')
.
Star Strider
le 14 Avr 2026 à 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
le 14 Avr 2026 à 23:26
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Catégories
En savoir plus sur Surfaces, Volumes, and Polygons dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


