Storing a variable and calling it out again to use and plot
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
From what i understand in this question, I need to store the current temperature,T of the following into a new variable T_old and update each value of T accordingly. But when i plotted it out there is an aerror. Also i cannot seem to store the T into T-old and calling it out to use. This is my codes for the first part.
x =-0.8:0.8:5;
dt=1000;
T=ones(1,5); T(1,5)=40;
figure
plot(x,T)
title('Temperature distribution between x=0 and x=0.8 ')
xlabel('x')
ylabel('Temperature')
hold on;
T=T_old
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048585/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048590/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1048595/image.jpeg)
0 Commenti
Risposte (1)
vidyesh
il 20 Nov 2024
Hi Ellie,
The reason for the error is that number of elements/values in vector 'x' and and vector 'T' are different.
Consider using 'linspace' function to define x instead.
'linspace' will allow you to generate a vector from a start to end point with the desired number of elements.
Please refer the below documentation for more details.
Hope this helps.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!