residual r=ax-b ∞-norm

78 次查看(过去 30 天)
dulanga
dulanga 2019-3-18
评论: dulanga 2019-3-19
This is my code but i dont get the coorect answer
a = [-5 8 -5; 0 0 12; 3 -7 -3;6 -4 4]
b = [1;1;1;1]
x=a\b
r=a*x-b
x1=sqrt(sum(r.*r))

采纳的回答

dulanga
dulanga 2019-3-19
Would this be correct to get infinty norm
a = [-5 8 -5; 0 0 12; 3 -7 -3;6 -4 4]
b = [1;1;1;1]
x=a\b
r=a*x-b
N = norm(r, Inf)
  4 个评论
John D'Errico
John D'Errico 2019-3-19
That is correct, as long as you are allowed to use the norm function. Things like that are sometimes not allowed in homework. If not, then you need to do as I suggested, as
max(abs( r ))

请先登录,再进行评论。

更多回答(1 个)

John D'Errico
John D'Errico 2019-3-19
Why would you possibly have expected to get the right answer? Was the infinity norm requested? Is it a 2-norm that you computed?
x1=sqrt(sum(r.*r))
If r is the vector of residuals, then what do you want to compute? It seems like you want the maximum of the absolute value of the residuals. How would you do that?

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by