小编hhh*_*hhh的帖子

为什么不是球形图?如何在Matlab中绘制3D极坐标图?

[r,t] = meshgrid(linspace(0,2*pi,361),linspace(0,pi,361));
[x,y]=pol2cart(sin(t)*cos(r),sin(t)*sin(r));
%[x,y]=pol2cart(r,t);
surf(x,y);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我玩这个插件,但试图找到一个默认的功能.我该怎么做3D极坐标图?

我正在努力帮助这个人在这里诋毁不同的积分.

math matlab polar-coordinates

2
推荐指数
1
解决办法
2万
查看次数

如何在Matlab中嵌套匿名函数?

我有一个存储匿名函数的文件funcs.m.它们必须可以被目录中的文件使用.目前,我使用匿名函数,以便我funcs.m在不同的文件中执行该文件,但我认为这是一种错误的做事方式.其他函数如main.m及其嵌套函数nest.m需要使用funcs.m中的匿名函数.我认为路径不会解决这个问题,因为文件在同一个文件夹中.基本上我可以通过将匿名函数复制粘贴到每个文件来解决这个问题,但代码闻起来如此:

有没有办法在Matlab中重用具有anon函数的funcs.m?

的main.m

function main
funcs; % loads the anonymous functions
nest(par1,...,parN)
end
Run Code Online (Sandbox Code Playgroud)

nest.m

function nest(par1,...,parN)
funcs; %ERRR: This fires err, why? Look: this was sourced already in main.m!
function neededOnlyHere(par100)
    bq(q,A) %This needs the functions of the funcs
end

neededOnlyHere(somePar) %ERR to use the anon funcs from funcs
end
Run Code Online (Sandbox Code Playgroud)

函数main.m和nest.m使用此函数funcs.m具有匿名函数

bq=@(q,A) q*A;                              %Bolded q
I=@(ii,jj,A) find(A(ii,:)==1 & A(jj,:)==0); 
AiNotj=zeros(1,Ncut);                       
...
Run Code Online (Sandbox Code Playgroud)

错误

Attempt to add "bq" to a static workspace.
 See MATLAB Programming, Restrictions on
 Assigning to …
Run Code Online (Sandbox Code Playgroud)

matlab nested anonymous-function

2
推荐指数
1
解决办法
1854
查看次数

Python的列表理解中的平等性

我已经忘记了Python的列表理解中的平等性

[str(a)+str(b)+str(c) for a in range(3) for b in range(3) for c in range(3)]
['000', '001', '002', '010', '011', '012', '020', '021', '022', '100', '101', '102', '110', '111', '112', '120', '121', '122', '200', '201', '202', '210', '211', '212', '220', '221', '222']
Run Code Online (Sandbox Code Playgroud)

在哪里我想限制a!= b和b!= c.for a!=b for b!=c最后没有奏效.那么如何在列表理解中使用等式约束呢?

python list-comprehension

2
推荐指数
1
解决办法
516
查看次数

Matlab:抑制fmincon的标准输出?

我想抑制fmincon的标准输出,如下所示

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the default value of the function tolerance,
and constraints are satisfied to within the default value of the constraint tolerance.

<stopping criteria details>

Active inequalities (to within options.TolCon = 1e-06):
  lower      upper     ineqlin   ineqnonlin
    1          1                      
    2          2                      
    3          3                      
    4          4                      
    5          5                      
    6          6                      
    7          7      
Run Code Online (Sandbox Code Playgroud)

每次我使用 fmincon 查找多元函数的最小值时都会触发它。

    x0=lb; %guess
    A=[];
    b=[];
    Aeq=[];
    beq=[];

    global mlf1;
    mlf1=mlf;
    [x,fval]=fmincon(@HenriMLF.mlfEvalAtPoint,x0,A,b,Aeq,beq,lb,ub);
Run Code Online (Sandbox Code Playgroud)

那么如何抑制fmincon的stdout呢?

matlab stdout verbosity

2
推荐指数
1
解决办法
3559
查看次数

ggplot2 中的广义矩阵散点图?

我想创建一个大小的网格划分NN哪里N是字段数。我试图得到的网格图有点像 Weka 中的图:一个多图,其中每一行都是数据框的一个字段,每列也是一个字段。诀窍是我想获得矩阵散点图的更通用版本。我想要更丰富的数据,没有重复:例如,对角线值可以有分布。

威卡。矩阵散点图浪费了很多空间,我们可以丰富它吗?

在此处输入图片说明

基本的R解决方案1.plot(iris)同样的浪费空间的问题,为什么我们有对角线?

在此处输入图片说明

看起来像是从维基百科以某种方式使用 R 基本命令创建的 R 解决方案 2。

在此处输入图片说明

R 中的小演示(计算时间太长)

library(gridExtra)
library(grid)
library(ggplot2)
#library(lattice)
data(iris) 
p1 <- ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Length)) + geom_point()
p2 <- ggplot(data=iris,aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()
p3 <- ggplot(data=iris,aes(x=Sepal.Length, y=Petal.Length)) + geom_point()
p4 <- ggplot(data=iris,aes(x=Sepal.Length, y=Petal.Width)) + geom_point()
p5 <- ggplot(data=iris,aes(x=Sepal.Length, y=Species)) + geom_point()
grid.arrange(p1, p2, p3, p4, p5, ncol=length(names(iris)))
#ERROR: In as.list(X): reached elapsed time limit
# https://cran.r-project.org/web/packages/gridExtra/vignettes/arrangeGrob.html
Run Code Online (Sandbox Code Playgroud)

及其会话信息

version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: …
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2 weka tidyverse

2
推荐指数
1
解决办法
1万
查看次数

浏览器的搜索框如何工作?

我需要准确地知道浏览器上的搜索框是如何工作的.我想用数学中的自定义搜索引擎替换搜索内容,例如维基百科和谷歌.您可以在iGoogle中看到它们.所以:

如何将Google CSE添加到浏览器的搜索框中?

google-custom-search

1
推荐指数
1
解决办法
1652
查看次数

如何使用Perl重新排列此模板中项目的顺序?

如何将以下匹配转换为给定结果?

我的文件有以下匹配项

-- cut --
Lorem ipsun Hello lorem ipsun { $hello } 
@param integer $question_id                   // example of the match
Lorem ipsun Hello lorem ipsun { $hello } 
-- cut --
Run Code Online (Sandbox Code Playgroud)

我想有效地改变它们

@param $question_id integer
Run Code Online (Sandbox Code Playgroud)

我在伪代码中的尝试

perl -i.bak -pe `s/(@param) (\\w) ($\\w)/$1 $3 $2/`
Run Code Online (Sandbox Code Playgroud)

perl

1
推荐指数
1
解决办法
144
查看次数

Java:替换ArrayList中不允许的ArrayList cos原语类型?

ArrayList,source中不允许使用原始类型.部分解决方案:您可以将诸如int之类的prim.types包装到Integer中以形成一个额外的类但是副作用.我想索引数据,是否有一些替代ArrayList允许原始类型?

java arraylist primitive-types

1
推荐指数
1
解决办法
4120
查看次数

为什么错误"非法字符:^ M"?

我得到了一些我无法理解的格式问题,下面是一个使用Zsh的简短示例.为什么?

$ values=( 300 400 )
$ echo "scale=20; $values[1]-$values[2]" | bc
(standard_in) 1: illegal character: ^M         // Why does it not print -100?
$ echo $values                                 // no ^M sign found!
300 400
Run Code Online (Sandbox Code Playgroud)

帮助者的问题

  1. 为什么5E 4d 0a,即^MASCII中的第13个字符?
  2. 为什么结尾符号"0a"显示为点"."?"." 十六进制是"2E".

unix windows format ascii zsh

1
推荐指数
1
解决办法
5274
查看次数

Java:为什么声明在界面上不够用?

大类包含Format-interfcase和Format-class.Format-class包含方法,接口具有字段的值.我可以在类Format中使用字段,但目标是使用Interface.那么我只是创建虚拟变量以消除错误,设计问题或ELSE?

KEY:声明VS初始化

  1. 通过术语解释,为什么你必须在接口中初始化.
  2. 它背后的逻辑是什么?
  3. 它引导界面使用哪种问题?

示例代码具有init-interface-problem

import java.util.*;
import java.io.*;

public class FormatBig
{

        private static class Format implements Format
        {
                private static long getSize(File f){return f.length();}
                private static long getTime(File f){return f.lastModified();}
                private static boolean isFile(File f){if(f.isFile()){return true;}}
                private static boolean isBinary(File f){return Match.isBinary(f);}
                private static char getType(File f){return Match.getTypes(f);}
                private static String getPath(File f){return getNoErrPath(f);}
                //Java API: isHidden, --- SYSTEM DEPENDED: toURI, toURL


                Format(File f)
                {
                  // PUZZLE 0: would Stack<Object> be easier?
                        size=getSize(f);
                        time=getTime(f);
                        isfile=isFile(f);
                        isBinary=isBinary(f); …
Run Code Online (Sandbox Code Playgroud)

java initialization interface declaration

1
推荐指数
1
解决办法
212
查看次数