26 views (last 30 days)

hello expert,

Am new to matlab. please i need help on how to generate a code that would claculate this equation.

D = C x P ^a x t^b

the vaues of a, b, c are constants with values c =3.62e-7; a =2.416; b = 0.785

the values of P and t are in a .txt file output in columns as attached. t represent time and p represent stress.

please your guidance will help alot

best regards,

KSSV
on 28 Jul 2020

Edited: KSSV
on 28 Jul 2020

Read about textscan.

fid = fopen('Myfile.txt','r') ;

S = textscan(fid,'%f %f\n','HeaderLines',4) ;

S = S{1} ;

fclose(fid) ;

S should be a n*2 matrix. Read baout textscan if the code is not working properly.

dpb
on 28 Jul 2020

There's no point at all in using textscan on such a simple file format... importdata does it all on its own as shown above; readmatrix would also do it w/ just 'NumHeaderlines' as additional argument.

Your attempts at positioning a file with fseek are totally misguided -- fseek moves by BYTES not records; the file is not fixed-length records so you can't count characters reliably anyway and is probably tab delimited (altho I didn't open it to check; there's no need nor sense in pursuing that depth).

If you were adamant on using textscan, as KSSV says, "READ THE DOCUMENTATION!" and just fix the typo.

There's no point in giving advice/guidance if not going to pay any attention to it... :(

Opportunities for recent engineering grads.

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

Start Hunting!
## 29 Comments

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952579

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952579

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952609

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952609

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952732

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952732

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952768

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952768

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952777

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952777

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952795

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952795

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952816

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952816

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952819

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952819

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952840

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952840

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952843

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952843

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952858

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952858

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952882

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952882

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952900

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_952900

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953197

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953197

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953248

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953248

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953383

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953383

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953722

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953722

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953749

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953749

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953752

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953752

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953764

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953764

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953833

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953833

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953842

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953842

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953860

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953860

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953911

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953911

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953932

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953932

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953944

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_953944

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_961630

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_961630

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_986627

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_986627

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_986693

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/571669-code-to-read-files-from-ansys-fluent-and-perform-calculations#comment_986693

Sign in to comment.