too many input arguments. matlab,matlab报错too many arguments,求帮助解决

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

函数M文件定义:

function Result=Markov(P,x,y,c)

%P为一步转移概率矩阵,x为初始等级,y为目标等级,c为各个等级上进行一次升级操作的投入。

%返回结果Result=[upgrade_time,total_cost]:

% 1、upgrade_time为从x升级到y的升级次数期望;

% 2、total_cost为此过程中总消耗的期望。

%一、求P矩阵的阶数:

[P_size,n]=size(P);

%二、工具矩阵:

I=eye(P_size);

Ix=zeros(1,P_size);Ix(x)=1;

Iy=zeros(P_size,1);Iy(y)=1;

Ey=I;Ey(y,y)=0;

%三、计算过程:

if x==y

upgrade_time=0;

total_cost=0;

else

upgrade_time=Ix*(I-P*Ey)^-2*P*Iy;

total_cost=Ix*((I-P*Ey)^-1*P+I)*Ey*c*;

end

Result=[upgrade_time,total_cost];

主程序:

clc;

clear all;

format short;

P=[0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.40 0.60 0.00 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.60 0.40 0.00 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.80 0.20 0.00 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.90 0.10 0.00 0.00 0.00

0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.92 0.08 0.00 0.00

0.93 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.07 0.00

0.94 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.06];

x=input(*输入基础等级: *);

y=input(*输入目标等级: *);

c=[1 1 1 1 1 1 1 1 1 1];

[upgrade_time,total_cost]=Markov(P,x,y,c);

fprintf(*从等级%g强化到等级%g,平均需要进行%g次强化。\n*,x,y,upgrade_time);

fprintf(*从等级%g强化到等级%g,一共需要消耗%g个宝石。\n*,x,y,total_cost);

这是一个装备模拟强化的程序,看了半天还不是不知道错误在哪,求帮助!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值