7 views (last 30 days)

Am looking at plotting the graph for P vs exposure time, P vs stress, and P vs time vs stress(all in one graph), and finally calculate the cumulative value for P as captured in the equation 1 below

The values for stress and exposure time is read from a .xy file format ( i atatched it here as a .txt file) with two columns and a long list of rows. Let’s say 2000 rows with different values for time and stress at every point.

The expression for D is captured below

P = F x stress^a + time^b….. ………..(1)

Where

a, has a constant value of 2.416

b has a constant value of 0.785

And F with a constant value of 3.62 x 10-7

Please note: The values of (stress) and t (exposure time) is read from a file. But the computation required to get the exact value of stress and time from the read file is

current value for shear stress=(current row+previous row)/2------------------(2)

current value for exposure time=current time-previous time=∆t---------(-3)

Put the calculated values for each current value of time and stress to calculate the D values based on equation 1

please how do i go about implementing this in matlab. i have imported the attached diument in MATLAB, seperating this variables and implementing the above equations for 2 and 3 for this sets of values is a challenge. can any one guide me.

Rik
on 22 Aug 2020

Well, if that is the input, then this edit to your function should work:

function P = damage(time,stress)

a = 2.416;

b = 0.785;

f = 3.62*10^-7;

P = f* (stress.^a) + (time.^b);

% ^ ^

% use element-wise power, instead of matrix multiplication

end

Opportunities for recent engineering grads.

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

Start Hunting!
## 8 Comments

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981125

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981125

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981254

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981254

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981290

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981290

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981347

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981347

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981635

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981635

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981671

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_981671

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_986645

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_986645

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_1054271

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/582749-calculation-of-average-and-difference-from-imported-data#comment_1054271

Sign in to comment.