difference between two double vector?

조회 수: 7 (최근 30일)
Jack Moriss
Jack Moriss 2016년 8월 17일
댓글: Jack Moriss 2016년 8월 18일
Hi. I am new in matlab so if you help me I will be grateful. I do not know the difference between these two data:
p=[0.0476 0.1429 0.0952 0.0476 0.0476 0.1429 0.0476 0.0476 0.0952 0.0952 0.0476 ]
and
p =
Columns 1 through 11
0.0476 0.1429 0.0952 0.0476 0.0476 0.1429 0.0476 0.0476 0.0952 0.0952 0.0476
When I use the first data in a function the answer is correct but the second one is not. How can I save the second one like the first one and then use it?

답변 (2개)

Image Analyst
Image Analyst 2016년 8월 17일
They're the same. The first one is just the code - how the variable is assigned. It's how it looks in the editor window. If you execute that code, it will show up like you have in the second section. That's just how it looks in the command window and will echo there if you don't put a semicolon on the end of the line. That is not something that you'd actually execute as part of your script - it's just the displayed output of an assignment command.
Beyond that, I'm not really sure what you want to do. You obviously already have p because you displayed it in the command window, so just start using it. Why do you think you need to do anything other than use "p"???
  댓글 수: 3
Image Analyst
Image Analyst 2016년 8월 17일
So go ahead and us p. There should be no problem.
Jack Moriss
Jack Moriss 2016년 8월 18일
but the answer is not correct.i know both of them are the same but have different result in function

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2016년 8월 18일
At the command prompt give the command
format long g
and then display p (the right one) again. You will find that the values are not exactly the same as in your code: the values only round to be the same. You can then check further by subtracting the p from your code from the right p and showing the difference between them.
  댓글 수: 1
Jack Moriss
Jack Moriss 2016년 8월 18일
thanks now i know where is the problem and solve it

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by