Varying two variables in a for loop for one output

조회 수: 3 (최근 30일)
Michael
Michael 2025년 4월 30일
댓글: Michael 2025년 4월 30일
These values are used later on to obtain 1 output that will be plotted in a 3d plot. I want to run a for loop where m(1) is compared to all the n values then the same will happen for m(2) and so on until I get all the possible points.
for index = 1:1:45
n = N_range(index);
m = m_water_range(index);
MW = m/nr;
MG = 1.6/Nr;
  댓글 수: 2
Cris LaPierre
Cris LaPierre 2025년 4월 30일
There are not enough details to provide a solution.
How are you comparing the values? Why are you comparing them? What is the value of nr and Nr? What is your output? Where should your for loop end?
Michael
Michael 2025년 4월 30일
small typo on my part the n and nr are supposed to be the same values. I am trying to get an output of temperature with the m being a mass flow rate and the n being number of channels in a heat exchanger. here are the values of the ranges
m_water_range = linspace(5,40,45);
N_range = linspace(5,50,45);

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2025년 4월 30일
I would remove the for loop and use meshgrid instead.
m_water_range = linspace(5,40,45);
N_range = linspace(5,50,45);
[m,n] = meshgrid(m_water_range,N_range);
MW = m./n;
MG = 1.6./n;
surf(m,n,MG)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by