How can I specify a tolerance for data written in two text files?

Kindly, I have data in two text files (e.g. attached) having one column each (y) and (x). I need to specify a tolorance as follows
1- combined these two text files in one.
2- get the difference between these two columns (e.g. (y^2 - x^2)^0.5 = value
3- write an output which is the maximum difference of the whole set (one value).

Answers (1)

Sounds like homework:
1) Load the files assign it to a variable x and y.
2) Use it in the formula.
3) Use max() to find the maximum value.
4) Use dlmwrite() or any other function to export it to a text file.

5 Comments

Show the code that you have tried.
I tried this code but doesnot work!
ex1 = load('x.txt');
ey1 = load('y.txt');
X1 = repmat(ex1(:,1), 1);
Y1 = repmat(ey1(:,1), 1);
TL = max(Y1.^2 - X1.^2).^0.5;
x = load('x.txt');
y = load('y.txt');
Values = sqrt(y.^2 - x.^2);
Maximum_value=max(Values)
This is the same as mine!! I should have the absolute values in another word
-3.65 and -3.31 the difference should be 0.34
also the difference between -2.67 and -2.61 is -0.06
thank you
Use
-(y-x)% instead of sqrt(y^2-x^2)
Btw I am confused :D

Sign in to comment.

Asked:

ND
on 31 Jan 2019

Edited:

on 31 Jan 2019

Community Treasure Hunt

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

Start Hunting!