ML算法matlab仿真,出现??? Undefined command/matlab中s functionn 'modulation'. 求修改......

新人跪求帮助!!为啥出现Undefined command/function【matlab吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:188,557贴子:
新人跪求帮助!!为啥出现Undefined command/function收藏
借用了GPRMAX的M文件 命令栏输入
fileout = 'bre1.out';
[Header,Fields]=gprmax(fileout);
N=1:Header.NS
Position=Header.dx*Header.tx+(N-1)*(Header.dx*Header.TxStepX); %天线每次所在位置
Data(:,:)=Fields.ez(:,1,:);
%转换数组格式
figure(2);
imagesc(Position,Fields.t*1e9,Data);%画图
xlabel('Antena Position (m)');
ylabel('t(ns)');后出现Undefined command/function 'gprmax2g' 是为啥啊。。网上有人说是没有放在同一个目录下 应该把GPRMAX软件放在MATLAB哪个目录下?
企业版MATLAB中文官方试用下载,让工程师和科学家更高效地进行科学计算.
楼主问题解决了吗?
登录百度帐号推荐应用精通MATLAB 张志涌编着 (Matlab入门经典教程) - 企业文化-
当前位置:
精通MATLAB 张志涌编着 (Matlab入门经典教程)
馆藏:11600
下载此文档
同系列文档
Baidu Button END -->
官方公众微信查看: 11100|回复: 17|关注: 0
用Matlab遗传算法对一元函数求最大值
<h1 style="color:# 麦片财富积分
新手, 积分 41, 距离下一级还需 9 积分
关注者: 5
这是用遗传算法工具箱函数对一元函数就最大值的代码和运行结果,考虑到大家下载附件还得花M币,所以把代码贴出来了。
希望对初学遗传算法的朋友有帮助。当然,正在研究GA的朋友,我们可以一起研究,共同进步。呵呵。。
figure(1);
fplot('variable.*sin(10*pi*variable)+2',[-1,2])
MAXGEN=25;
trace=zeros(2,MAXGEN);
FieldD=[20;-1;2;1;0;1;1];
Chrom=crtbp(NIND,PRECI);
variable=bs2rv(Chrom,FieldD);
ObjV=variable.*sin(10*pi*variable)+2;
while gen&=MAXGEN
& & FitnV=ranking(-ObjV);
& & SelCh=select('sus',Chrom,FitnV,GGAP);
& & SelCh=recombin('xovsp',SelCh,0.7);
& & SelCh=mut(SelCh);
& & variable=bs2rv(SelCh,FieldD);
& & ObjVSel=variable.*sin(10*pi*variable)+2;
& & [Chrom ObjV]=reins(Chrom,SelCh,1,1,ObjV,ObjVSel);
& & gen=gen+1;
& & [Y,I]=max(ObjV),
& &plot(ObjV(I),Y,'r^')
& & trace(1,gen)=max(ObjV);
& & trace(2,gen)=sum(ObjV)/length(ObjV);
variable=bs2rv(Chrom,FieldD);
plot(variable',ObjV','r^')
figure(2);
plot(trace(1,:)')
plot(trace(2,:)')
25代之后种群中个体所对应的函数值分布情况:
1.jpg (45.01 KB, 下载次数: 31)
19:42 上传
25代之后,种群最有解和种群均值的变化情况:
2.jpg (30.12 KB, 下载次数: 19)
19:42 上传
[ 本帖最后由 mooni 于
19:44 编辑 ]
碌碌无为地工作,默默无闻地生活。
<h1 style="color:# 麦片财富积分
有的函数确实有最优解,但用Matlab遗传算法却找不到,为什么?当程序运行后,第一次生成的解就不再发生改变了,这样一直都找不到满足条件的最优解。请问这种情况该怎么处理,请指教,谢谢!!!
<h1 style="color:# 麦片财富积分
关注者: 1
原帖由 gh0718 于
20:47 发表
有的函数确实有最优解,但用Matlab遗传算法却找不到,为什么?当程序运行后,第一次生成的解就不再发生改变了,这样一直都找不到满足条件的最优解。请问这种情况该怎么处理,请指教,谢谢!!! ...
matlab做优化问题很懒惰,找到一个满足它的tolerance的解以后就不会再去找第二个解了,fzero,fminsearch,fmincon,......,包括求解线性方程组,等等都是如此。所以,不建议用mablab做优化问题。做优化问题目前还是1stopt,lingo好。
<h1 style="color:# 麦片财富积分
关注者: 5
回复 3# mathjiang 的帖子
基于matlab的遗传算法主要就是做优化的。
碌碌无为地工作,默默无闻地生活。
<h1 style="color:# 麦片财富积分
那您能告诉我我的这种情况该如何处理,采用自适应还是有其它更好的办法?急用,谢谢!!!
<h1 style="color:# 麦片财富积分
我现在在用GUI来实现遗传算法
发现每次运行啊
如果使用混合函数,结果都能更优化些
楼主可以试试
<h1 style="color:# 麦片财富积分
回复 1# 2009zhanglei 的帖子
我把你的代码完全复制用的,却出来了这样的一个图,请教图1是怎么回事,谢谢
[ 本帖最后由 comrise 于
19:31 编辑 ]
<h1 style="color:# 麦片财富积分
运行程序怎么出现这个
??? Undefined command/function 'crtbp'.
Error in ==& Untitled3 at 23
Chrom=crtbp(NIND,PRECI);
<h1 style="color:# 麦片财富积分
楼主辛苦!
<h1 style="color:# 麦片财富积分
谢谢楼主。
站长推荐 /1
MATLAB中文论坛是全球最大的 MATLAB & Simulink 中文社区。用户免费注册会员后,即可下载代码,讨论问题,请教资深用户及结识书籍作者。立即注册加入我们吧!
MATLAB官方社交平台
MATLAB中文论坛微社区MATLAB Standalone Executables :
TechWeb : Boston University
MATLAB Standalone Executables
If you run MATLAB jobs routinely, you may have had the experience of denied MATLAB access or having your MATLAB batch jobs killed due to unavailable MATLAB licenses. This can be avoided if you compile your MATLAB application into an executable with the MATLAB mcc compiler. A standalone executable runs without using a MATLAB license, and has several other benefits.
Benefits of standalone executables
Broader distribution: Extend the reach of your program to users who lack a MATLAB license.
Access reliability: Standalone executables never fail due to license availability.
Embarrassingly parallel applications: Hundreds or thousands of independent runs are common for many applications. Using a standalone makes it possible to run these tasks concurrently &#8212; e.g. on the SCC cluster &#8212; without running into licensing issues.
Hide source code for intellectual property protection
To be compatible with the MATLAB mcc compiler, your program must meet a few requirements. The most important of these are listed below.
The starting, or &#8220;main,&#8221; program must be a function — with or without returning output. The standalone, regardless, will not return any output. You can use either the original main or you create a
wrapper as the new &#8220;main&#8221; which in turn calls the original main. For many, a wrapper may be more appealing as it enables the original program to be kept completely separate from the corresponding standalone program.
All runtime input parameters are always passed to the standalone as strings. Any passed string parameter intended as double in the code must be converted with str2double. Your wrapper will perform data type conversions (if any) and pass them to the original main for further processing.
Compilation
scc1% module load matlab/2016a
scc1% mcc -mv -o myExecR2016a myStandalone.m myApp.m
-mv produces a standalone and shows actions taken
-o myExecR2016a specifies the executable name. Though not required, &#a&#8221; suffix in the output name indicates MATLAB release used for compilation.
Running Standalone executable interactively
qrsh -pe omp 4
scc-pi4% module load mcr/9.0.1_2016a
scc-pi4% mcr ./myExecR 4
scc-pi4% exit
Submit a job
Example batch script to submit a standalone MATLAB executable
#!/bin/bash -l
# SGE script for MATLAB standalone
# scc1$ qsub run_standalone_job
# Merge output and error files in one
# Send email when job finished or aborted
# Request 4 cores
#$ -pe omp 4
module load mcr/9.0.1_2016a
mcr ./myExecR 4
Example Source Files
myApp function
function s = myApp(n, nslots)
% function s = myApp(n, nslots)
% Purpose: runs basic MATLAB commands to simulate user code for a standalone demo
n: size of arithmetic sequence [1+2+3+ . . . +n]
nslots: number of processors in parallel computing
% Compute with the Parallel Computing Toolbox
fprintf(1,'\n Test the parallel computing toolbox . . . . .\n');
fprintf(1,'Parfor will be used to compute the sum of the arithmetic sequence\n');
fprintf(1,'s = 1 + 2 + 3 + . . . + n = n(n+1)/2\n\n');
fprintf(1,'Will use %d threads for parfor operations.\n', nslots);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Especially important for running multiple batch jobs
% Without this procedure, some batch jobs may fail
% redirects ~/.matlab PCT temp files to system's TMPDIR on compute
% node to avoid inter-node (compute node &--& login node) I/O
myCluster = parcluster('local'); % cores on compute node are "local"
if getenv('ENVIRONMENT')
% true if this is a batch job
myCluster.JobStorageLocation = getenv('TMPDIR')
% points to TMPDIR
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
parpool(myCluster, nslots);
% MATLAB R2014a or newer
%matlabpool(myCluster, nslots);
% MATLAB R2013b or older
% REPLACE BELOW EXAMPLE WITH YOUR APP
% This example uses parfor to compute arithmetic sequence sum
% initialize sequence sum s
parfor i=1:n
% s = 1 + 2 + 3 + . . . + n
% close parallel pool for R2013 or older
delete(gcp)
% close parallel pool for R2014a or newer
fprintf(1,'\n\n Iteration count n = %d\n', n);
fprintf(1,'\nComputed s = %
Expected s =
%d \n\n', s, n*(n+1)/2);
% end of function
myStandalone wrapper script
function myStandalone(n, nprocs)
if ischar(n) == 1
disp('n needs conversion')
n = str2double(n);
% convert string to double
if ischar(nprocs) == 1
disp('nprocs needs conversion')
nprocs = str2double(nprocs);
% convert string
% Call user app, myApp (script or function m-file)
s = myApp(n, nprocs);
% Handle the output (s) as intended
disp(['Sum of Arithmetic sequence 1+2+3+...+n = ' num2str(s)])
if isdeployed
% in standalone mode . . .
Additional notes
All supportive user m-files must be included for compilation.
Consult the
section for unsupported commands and toolboxes.
If a wrapper is not used, myApp.m must be a .
myStandalone.m is an optional application-dependent wrapper and is a command function. Note that, because myApp.m takes two input parameters — by design rather than mandatory — myStandalone.m retains the same 2 run time input.
The following command might need to be added into your matlab script to help myStandalone.m find files it needs:
&& addpath my/script/dir
% your m-files folder
Recompiling required whenever changes are made to one or more m-files.
For batch processing, mcc runtime option (e.g., -R -singleCompThread) may be required if you run a single threaded job.
mcc -mv -o myExec myStandalone.m myApp.m -R -singleCompThread -R -nodisplay
-R -singleCompThread turns off multithreading while -R -nodisplay disables graphics display.
The standalone built with these runtime switches will always run with single thread and will not display graphics — in batch or interactive.}

我要回帖

更多关于 matlab中s function 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信