How to correctly code the expression with Ei function?

Click For Summary

Discussion Overview

The discussion revolves around coding an equation involving the Ei function in Matlab. Participants are addressing issues related to the implementation of the code, specifically focusing on indexing errors and the structure of the code. The scope includes technical coding assistance and debugging.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant shares their Matlab code and describes an error message indicating that the index exceeds matrix dimensions.
  • Another participant requests a clearer analytic formulation and suggests improving the code's readability with comments and proper indentation.
  • A participant points out that the variable 't' is a constant, leading to a misunderstanding in the loop where 't(i)' is accessed, which only has one element.

Areas of Agreement / Disagreement

Participants generally agree on the need for clearer code and the identification of the indexing issue, but there is no consensus on the overall approach to resolving the coding problem.

Contextual Notes

The discussion highlights potential limitations in understanding the structure of the input data and the implications of using a constant variable in a loop.

Ein Krieger
Messages
32
Reaction score
0
Hi,

I am trying to incorporate the following equation into Matlab in the red:

http://http://www.radikal.ru][PLAIN]http://s018.radikal.ru/i518/1305/16/1cc0d2a72d38.jpg

The following data is to be used:
t=3000000
nr=nx=161
q=0.02
k=5e-13
mu=0.00035
c=1.5e-8
phi=0.25
rw=0.1
h=4.5


My code is below:
st=size(t)
nr=nx;
for i=1:1:st(1)
rd=r(1:nr)/wb
td=0.0036*k*t(i)/(phi*mu*c*wb^2)
pd=((pi*h*k)/(1.842*q*1.1*mu))*(IP-p(i,1:nr))
Ei_from_mfun=mfun('Ei',1,-rd^2/(4*td))
pd=1/2*Ei_from_mfun
plot(time,pd,'bo')
end

But it gives the following command :
"? Index exceeds matrix dimensions."

Can you please help to fix the problem for every time, t and pressure,p?

Thanks
 
Physics news on Phys.org
Provide the analytic formulation and tidy your code a little, pls.
E.g. comments and indentation would not hurt; there a "code tags" button in the editor widget you can use to preserve indentation blanks in the code block.
 
Solkar said:
Provide the analytic formulation and tidy your code a little, pls.
E.g. comments and indentation would not hurt; there a "code tags" button in the editor widget you can use to preserve indentation blanks in the code block.

Here is the equation to be solved :

ff5083bd4721.jpg


The red equation belowi the analytical solution I want to get solution for.

The data to be used:
The following data is to be used:
t=3000000
r=nr=nx=161
q=0.02
k=5e-13
mu=0.00035
c=1.5e-8
phi=0.25
rw=0.1
h=4.5

My code is below:

Code:
st=size(t)
nr=nx;
for i=1:1:st(1)
rd=r(1:nr)/wb
td=0.0036*k*t(i)/(phi*mu*c*wb^2)
pd=((pi*h*k)/(1.842*q*1.1*mu))*(IP-p(i,1:nr))
Ei_from_mfun=mfun('Ei',1,-rd^2/(4*td))
pd=1/2*Ei_from_mfun
plot(time,pd,'bo')
end

But it gives the following command :
"? Index exceeds matrix dimensions."
 
Last edited:
t is a constant.

st=size(t) is then equal to [1 1]

the for loop runs through for i=1, but then halts on i=2 because you have t(i), and t(2) doesn't exist.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
Replies
2
Views
5K