how do i write this equation in matlab?
조회 수: 1 (최근 30일)
이전 댓글 표시
댓글 수: 1
Jan
2017년 7월 31일
@huma: What exactly is your question? There is a working M-version of the wanted function on the page. You explain, that you cannot run it, so please explain how you try it. Post the code and show us the error message (if there is one).
답변 (2개)
John BG
2017년 7월 30일
hi Huma
As Guillame points out, right in the web page pointed by your link in your question there's another link pointing at
that contains
% Authors: Sonja Surjanovic, Simon Fraser University
% Derek Bingham, Simon Fraser University
% Questions/Comments: Please email Derek Bingham at dbingham@stat.sfu.ca.
%
% Copyright 2013. Derek Bingham, Simon Fraser University.
%
% THERE IS NO WARRANTY, EXPRESS OR IMPLIED. WE DO NOT ASSUME ANY LIABILITY
% FOR THE USE OF THIS SOFTWARE. If software is modified to produce
% derivative works, such modified software should be clearly marked.
% Additionally, this program is free software; you can redistribute it
% and/or modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation; version 2.0 of the License.
% Accordingly, this program is distributed in the hope that it will be
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
%
% For function details and reference information, see:
% http://www.sfu.ca/~ssurjano/
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% INPUTS:
%
% xx = [x1, x2, ..., xd]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
d = length(xx);
sum = 0;
for ii = 1:(d/4)
term1 = (xx(4*ii-3) + 10*xx(4*ii-2))^2;
term2 = 5 * (xx(4*ii-1) - xx(4*ii))^2;
term3 = (xx(4*ii-2) - 2*xx(4*ii-1))^4;
term4 = 10 * (xx(4*ii-3) - xx(4*ii))^4;
sum = sum + term1 + term2 + term3 + term4;
end
y = sum;
end
Apparently the authors S.Surjanovic, S.Fraser have copyrighted the function, year 2013.
Yet in the abridged comment regarding the copy right, it's mentioned that it's free software, provided
- you clearly mention S.Surjanovic, S.Fraser as the authors of their code, and
- you make clear annotations regarding your modifications and additions.
Meeting the above and adding a GNU license file may suffice for you to use their code as you please.
In any case, why don't you contact them, at
say hello, and comment you intend to use their code, and then obtain an email from them with a go-ahead?
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
댓글 수: 4
Guillaume
2017년 7월 31일
@John, there is no apparently. The file is copyrighted. The authors have licensed it under the GNU GPL which means that you are free to use it for any purpose you want without having to ask them. However, if you distribute it, even in modified form, you must acknowledge them and your derived work must be licensed under the GNU GPL.
Nothing there is open to interpretation.
John BG
2017년 7월 31일
편집: John BG
2017년 7월 31일
Guillaume thanks for the comment, but your explanation is for Huma.
The 'apparently' is just a way to speak. I have recommended Huma to contact the authors because, you never know, perhaps there is a newer version.
May be the authors explain Huma how to run the function, because Huma asked how to use this function.
Guillame, do you know how to use it?
It's always good to get in contact with the authors, they may even consider enhancing the comments in the function and include an example how to use it.
But indeed you are right there's no need to do so, it's entirely up to Huma
참고 항목
카테고리
Help Center 및 File Exchange에서 Behavior and Psychophysics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!