Depends what you want the one value to represent?! It's a meaningless question otherwise. If the two vectors are the same length then a normal subtraction would give you a 3rd vector of that same length.
Until you define what the meaning of "a single number" is, in terms of mathematics, you cannot do anything. What would that number represent?
Two vectors. If the vectors are not the same length, then there is absolutely no meaning you can attribute to this, at least you have not done so.
Are the vectors of the same length? If they are, then you can subtract each element, IF that subtraction has any meaning. But then you have another vector of the same length. At best, you can compute some norm, as a measure of the aggregate size of the elements of that difference vector. You have not indicated this is your goal though. If that is what you wanted to do, then read the help for the function norm. You need to decide which vector norm is appropriate for your problem then.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
2 Comments
Adam (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/478569-subtracting-two-vectors-to-get-one-value#comment_741411
John D'Errico (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/478569-subtracting-two-vectors-to-get-one-value#comment_741413
Sign in to comment.