![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291588/image.png)
Nested for loop plots
2 views (last 30 days)
Show older comments
time_range = 1:10
for k_cotton = 0.04:0.02:0.08
for t = 1:1:length(time_range)
insert multiple variables as a function of (t)
code.....
Tskin_forearm(t) = k_cotton .* t .* variables(t)
code......
end
figure(1)
plot(time_range, Tskin_forearm)
grid on
xlabel('Time (seconds)')
ylabel('Temperature (Kelvin)')
legend('T skin .04','T skin .06','T skin .08')
title('Temperature of forearm over time')
end
Im shortening this code to make this easier. I am indexing within a nested loop. When the code goes to run k_cotton = 0.06 and then k_cottton = 0.08, it seems that the code is using indexed values from the previous k_cotton value. How do I fix this? In the end, I would like to plot the three Tskin_forearm values over time as a function of the three different k_cotton values.
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!