Pinv with martix different answer from command windows and script
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
So, so the commands works seperating in command windows but when i put into a script it seem to give me a different answer.
function x = script_21(A,b)
x=pinv(A)*b;
end
5 件のコメント
John D'Errico
2018 年 4 月 13 日
編集済み: John D'Errico
2018 年 4 月 13 日
No. Pinv works exactly the same way in a function, in a script, or in the command window.
What is common is that a beginning user does not pass in the same data. Or they do not display it in the same way. or they do not understand that functions have a different workspace. Or lots of things MAY have been done by you.
So, pass pinv different data, you will get a different answer. Display the result differently, get a different display.
We can't know what you did wrong, because you showed only a script where pinv was used. So show a complete example, where you think you got a different result. Show how it seems different to you. Then we can explain why you are wrong.
bondpen
2018 年 4 月 13 日
bondpen
2018 年 4 月 13 日
John D'Errico
2018 年 4 月 13 日
:)
As I expected. What often happens is you got sloppy. You called it with two different inputs, without realizing you did that. But you thought they were the same input.
One thing I learned a LONG time ago is to test everything I do. I know exactly what I have in every computation. Plot it. Look at the results. Verify everything, at every step. This teaches you to be careful. How did I learn that?
Because once, early in my career, I did some work for a client, getting an incredibly pretty result. I plotted it out. It was very nice looking. Then later, I tried to recreate what I did, doing what I thought I recalled having done before. I never did manage to get that pretty result, even from the original data. So what I must have done is screw it up. In some way, I created a result that looked like what I was expecting, what I wanted to see. It was just a mirage though.
bondpen
2018 年 4 月 13 日
回答 (0 件)
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!