用mahalanobis度量的matlab Pdist2(matlab Pdist2 with mahalanobis metric)
我如何使用'mahalanobis'指标使用pdist2? 我写这个代码:
u=[1 2 3; 4 5 6; 7 8 9]; n=[1 2 5;2 5 7;5 7 9]; covu=nancov(u); Z=pdist2(u,u,'mahalanobis',covu);
但我得到这个错误:
??? Error using ==> pdist2 at 298 The covariance matrix for the Mahalanobis metric must be symmetric and positive definite. Error in ==> Untitled at 5 Z=pdist2(u,u,'mahalanobis',covu);
尽管变量'covuu'是对称矩阵并且也是正的。 这是covu:covu =
9 9 9 9 9 9 9 9 9
我怎样才能用“mahalabobis”度量来计算pdist2?
How can i use pdist2 with 'mahalanobis' metric? I write this code :
u=[1 2 3; 4 5 6; 7 8 9]; n=[1 2 5;2 5 7;5 7 9]; covu=nancov(u); Z=pdist2(u,u,'mahalanobis',covu);
But i get this error:
??? Error using ==> pdist2 at 298 The covariance matrix for the Mahalanobis metric must be symmetric and positive definite. Error in ==> Untitled at 5 Z=pdist2(u,u,'mahalanobis',covu);
although variable 'covuu' is symmetric matrix and also positive. this is covu: covu =
9 9 9 9 9 9 9 9 9
How can i calculate pdist2 with "mahalabobis" metric?
原文:https://stackoverflow.com/questions/48443529
最满意答案
约定是,如果你不指定视图名称,相应的视图将是该操作的名称。 所以:
public ActionResult MethodA() { return View(); }
将呈现
~/Views/ControllerName/MethodA.cshtml
。但是你也可以指定一个视图名称:
public ActionResult MethodA() { return View("FooBar"); }
现在将呈现
~/Views/ControllerName/FooBar.cshtml
视图。或者,您甚至可以指定不在当前控制器的视图文件夹内的完全限定的视图名称:
public ActionResult MethodA() { return View("~/Views/Foo/Baz.cshtml"); }
显然,所有这些都假定Razor作为视图引擎。 如果您使用的是WebForms,请使用
.aspx
或.ascx
替换.cshtml
(如果您使用的是partials)。例如,如果没有视图,它甚至会告诉你在什么位置以什么顺序查找视图:
记住:ASP.NET MVC完全是关于约定而不是配置。
The convention is that if you don't specify a view name, the corresponding view will be the name of the action. So:
public ActionResult MethodA() { return View(); }
will render
~/Views/ControllerName/MethodA.cshtml
.But you could also specify a view name:
public ActionResult MethodA() { return View("FooBar"); }
and now the
~/Views/ControllerName/FooBar.cshtml
view will be rendered.Or you could even specify a fully qualified view name which is not inside the views folder of the current controller:
public ActionResult MethodA() { return View("~/Views/Foo/Baz.cshtml"); }
Now obviously all this assumes Razor as view engine. If you are using WebForms, replace
.cshtml
with.aspx
or.ascx
(if you are working with partials).For example if there is no view it will even tell you where and in what order is looking for views:
Remember: ASP.NET MVC is all about convention over configuration.
相关问答
更多-
尝试这个: <%= ViewContext.RouteData.Values["Controller"] %> <%= ViewContext.RouteData.Values["Action"] %> Try this: <%= ViewContext.RouteData.Values["Controller"] %> <%= ViewContext.RouteData.Values["Action"] %>
-
约定是,如果你不指定视图名称,相应的视图将是该操作的名称。 所以: public ActionResult MethodA() { return View(); } 将呈现~/Views/ControllerName/MethodA.cshtml 。 但是你也可以指定一个视图名称: public ActionResult MethodA() { return View("FooBar"); } 现在将呈现~/Views/ControllerName/FooBar.cshtml视图。 或者 ...
-
ASP.Net MVC 3:一个控制器动作的多个视图/ URL(ASP.Net MVC 3: Multiple views/urls to one controller action)[2021-12-13]
您可以创建一个操作,将视图名称作为参数; 像这样的东西: public ActionResult StaticPage(string viewName) { return View(viewName); } 然后定义一个路由,使viewName不是参数,而是URL的一部分: "/Static/{viewName}" You can make an action that takes as a parameter the name of the View; Something like this: ... -
虽然您可以使用返回部分视图的操作,但不需要执行部分视图呈现。 RenderPartial使用部分视图,并使用给定的模型渲染,并将数据(如果提供)查看到当前(父)视图中。 如果您使用AJAX加载/重新加载部分页面,则可能需要一个返回部分视图的操作。 在这种情况下,返回完整视图是不希望的,因为您只想重新加载部分页面。 在这种情况下,您可以使操作只返回与页面该部分对应的部分视图。 标准机制 在正常视图中使用部分视图(无需任何操作) ...some html... <% Html.RenderPartial( "P ...
-
这就是所谓的儿童行为。 调用Html.Action(...) 。 That's called a child action. Call Html.Action(...).
-
解决了路线。 这是唯一的方法。 感谢您的评论。 Solved with routes. It's the only way to do it. Thanks for comments.
-
我见过的建议是暗示视图与控件中包含的常见元素分离以保持干燥。 对控制器采取相同的方法似乎是合乎逻辑的 - 在适当的情况下重用公共部分。 这个视图在这里被镜像如何在ASP.NET.NET MVC中干净地重用编辑/新视图,因为问题非常相似。 The recommendations I've seen are suggesting that the views are separate with common elements contained within a control to stay DRY. It ...
-
-
如何从asp.net mvc中的视图传递数据到控制器操作?(How to pass data to controller action from view in asp.net mvc?)[2023-08-03]
codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)