Substituting by a matrix in an equation and getting a new matrix

조회 수: 2(최근 30일)
Mohamed Elasmar 2019년 5월 2일
댓글: Mohamed Elasmar 2019년 5월 7일
I have an equation for calculating the pressure gradient, which is and I have the following matrix where the first column is the values of phi and the other columns are the pressure cases which I want to calculate the pressure gradient for each of them.
(Note that: i in the equation refers to the position of the value in the column).
phi p1 p2 p3 p4 p5 p6 p7 p8 p9
-140.5000 1.3386 1.6004 2.4960 1.5004 2.0371 2.9061 1.5800 2.1815 3.1080
-140.0000 1.3424 1.6040 2.5028 1.5044 2.0431 2.9150 1.5848 2.1876 3.1167
-139.5000 1.3461 1.6076 2.5085 1.5085 2.0492 2.9235 1.5899 2.1941 3.1265
-139.0000 1.3495 1.6109 2.5143 1.5127 2.0553 2.9317 1.5948 2.2005 3.1366
-138.5000 1.3536 1.6147 2.5206 1.5171 2.0618 2.9395 1.5999 2.2073 3.1459
How can I substitute by the values of phi and pressure in the equation and get the following matrix?
phi p1/dphi dp2/dphi dp3/dphi dp4/dphi dp5/dphi dp6/dphi dp7/dphi dp8/dphi dp9/dphi
댓글 수: 5표시 이전 댓글 수: 4숨기기 이전 댓글 수: 4
Mohamed Elasmar 2019년 5월 7일
You are correct! I have already used the formula with (./) and it has successfully run showing the required results.
Thank you very much for your help!

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

답변(1개)

matrix=[matrix(:,1), (matrix(:,2:end)/2)]
2 is dphi

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

범주

Find more on Solver Outputs and Iterative Display 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!

Translated by