matlab

Equality results when using a matrix of strings

半城伤御伤魂 提交于 2021-02-10 12:56:03
问题 I don't understand why using == to compare between a string vector and a matrix of strings and the vector is of dimension n , I obtain a matrix of size n * n . I expected it to be of size n only, with a 1 when the string is equal. octave:13> t = ["aha";"bgb";"ctc"] t = aha bgb ctc octave:14> t == "aha" warning: mx_el_eq: automatic broadcasting operation applied ans = 1 1 1 0 0 0 0 0 0 What's going on underneath to explain such result ? And is it possible to do away with the warning: warning:

Equality results when using a matrix of strings

僤鯓⒐⒋嵵緔 提交于 2021-02-10 12:56:03
问题 I don't understand why using == to compare between a string vector and a matrix of strings and the vector is of dimension n , I obtain a matrix of size n * n . I expected it to be of size n only, with a 1 when the string is equal. octave:13> t = ["aha";"bgb";"ctc"] t = aha bgb ctc octave:14> t == "aha" warning: mx_el_eq: automatic broadcasting operation applied ans = 1 1 1 0 0 0 0 0 0 What's going on underneath to explain such result ? And is it possible to do away with the warning: warning:

Create DLL file from .c

北城以北 提交于 2021-02-10 12:07:31
问题 i'm tring to create a .dll file from this .c code (for Labview). http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek But i'm not able to compile it nor with VisualStudio nor with "mcc" because both compilers return this error: VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte VChooseK.obj : error LNK2019: unresolved

Create DLL file from .c

好久不见. 提交于 2021-02-10 12:01:33
问题 i'm tring to create a .dll file from this .c code (for Labview). http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek But i'm not able to compile it nor with VisualStudio nor with "mcc" because both compilers return this error: VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte VChooseK.obj : error LNK2019: unresolved

Create DLL file from .c

纵然是瞬间 提交于 2021-02-10 12:01:14
问题 i'm tring to create a .dll file from this .c code (for Labview). http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek But i'm not able to compile it nor with VisualStudio nor with "mcc" because both compilers return this error: VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte VChooseK.obj : error LNK2019: unresolved

Create DLL file from .c

二次信任 提交于 2021-02-10 12:01:05
问题 i'm tring to create a .dll file from this .c code (for Labview). http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek But i'm not able to compile it nor with VisualStudio nor with "mcc" because both compilers return this error: VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte VChooseK.obj : error LNK2019: unresolved

多项式最小二乘法拟合

和自甴很熟 提交于 2021-02-10 10:28:11
实用计算方法实验二——多项式最小二乘法拟合 实用计算方法实验二——多项式最小二乘法拟合 采用mlx,即matlab的实时脚本,便于观察结果和发布过程。 二次多项式 三次多项式 指数函数 评价拟合效果 附录:Doolittle函数解矛盾方程组 二次多项式 %二次多项式 最小二乘法 解矛盾方程组 拟合 %形如a0*1+a1*x+a2*x^2的拟合 clear clc x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]; y=[352 211 197 160 142 106 104 60 56 38 36 32 21 19 15]; m=size(x,2); %获得数据点个数 %n=input('请输入phi(x)的个数:'); n=3; %n即为phi(x)的个数 syms symsx f = symfun([1,symsx,symsx^2],symsx); %在这里可以修改phi(x)的表达式的形式与个数,如symsx^2,在建立法方程时的值为x^2,cos(symsx)则建立法方程时为cos(x) expr = formula(f); 表达式分别为 expr(1) ans = expr(2) ans = expr(3) ans = 构建的法方程的A与Y A=zeros(m,n); %构造法方程所需的A和Y for j=1:n temp =subs

Two simultaneous for loops MATLAB or C++

纵饮孤独 提交于 2021-02-10 07:34:33
问题 I'd like to run two dependent non-nested for loops. In essence they are two simultaneous Markov chains, where one loop needs to check a value in the other loop. Is it there a right way to do this? Is there a wrong/inefficient way to avoid? Imaginary example: Imagine two people are walking round a room and touching things: I record those things they touch in two separate arrays. Those are my two Chains or for loops. That's fine as long as their behaviour is independent. But I'd like to change

Can you preallocate an array of random size?

纵然是瞬间 提交于 2021-02-10 05:00:32
问题 The essential part of the code in question can be distilled into: list=rand(1,x); % where x is some arbitrarily large integer hitlist=[]; for n=1:1:x if rand(1) < list(n) hitlist=[hitlist n]; end end list(hitlist)=[]; This program is running quite slowly and I suspect this is why, however I'm unaware how to fix it. The length of the hitlist will necessarily vary in a random way, so I can't simply preallocate a 'zeros' of the proper size. I contemplated making the hitlist a zeros the length of

Can you preallocate an array of random size?

时间秒杀一切 提交于 2021-02-10 04:59:08
问题 The essential part of the code in question can be distilled into: list=rand(1,x); % where x is some arbitrarily large integer hitlist=[]; for n=1:1:x if rand(1) < list(n) hitlist=[hitlist n]; end end list(hitlist)=[]; This program is running quite slowly and I suspect this is why, however I'm unaware how to fix it. The length of the hitlist will necessarily vary in a random way, so I can't simply preallocate a 'zeros' of the proper size. I contemplated making the hitlist a zeros the length of