Clear Filters
Clear Filters

how do i write this equation in matlab?

1 view (last 30 days)
huma
huma on 29 Jul 2017
Edited: John BG on 31 Jul 2017
  1 Comment
Jan
Jan on 31 Jul 2017
@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).

Sign in to comment.

Answers (2)

Guillaume
Guillaume on 29 Jul 2017
How about following the link for the matlab implementation right on the very page you've linked?

John BG
John BG on 30 Jul 2017
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 Comments
Guillaume
Guillaume on 31 Jul 2017
@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
John BG on 31 Jul 2017
Edited: John BG on 31 Jul 2017
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

Sign in to comment.

Categories

Find more on Behavior and Psychophysics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!