MATLAB中简单程序但是图像不正确的问题clear;clc;R0=55;R1=100;R2=25;Pa=0.1;Pd=0.6;Pv=0.1;for r=0:0.1:100if (R2>r>=0)P=0.1;plot(r,P)hold onelseif(R0>=r>=R2)P=sqrt(Pd^2-(Pd^2-Pv^2)*log(r/R0)/log(R2/R0));plot(r,P)hold onelseP=sqrt(Pd^2-(Pd^2
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 13:54:41
MATLAB中简单程序但是图像不正确的问题clear;clc;R0=55;R1=100;R2=25;Pa=0.1;Pd=0.6;Pv=0.1;for r=0:0.1:100if (R2>r>=0)P=0.1;plot(r,P)hold onelseif(R0>=r>=R2)P=sqrt(Pd^2-(Pd^2-Pv^2)*log(r/R0)/log(R2/R0));plot(r,P)hold onelseP=sqrt(Pd^2-(Pd^2
MATLAB中简单程序但是图像不正确的问题
clear;
clc;
R0=55;
R1=100;
R2=25;
Pa=0.1;
Pd=0.6;
Pv=0.1;
for r=0:0.1:100
if (R2>r>=0)
P=0.1;
plot(r,P)
hold on
elseif(R0>=r>=R2)
P=sqrt(Pd^2-(Pd^2-Pv^2)*log(r/R0)/log(R2/R0));
plot(r,P)
hold on
else
P=sqrt(Pd^2-(Pd^2-Pa^2)*log(r/R0)/log(R1/R0));
plot(r,P)
hold on
end
end
这个程序在MATLAB中运行出来之后一直是一条直线,但是根据常识不可能一直是一个定值啊,这是怎么回事呢?
MATLAB中简单程序但是图像不正确的问题clear;clc;R0=55;R1=100;R2=25;Pa=0.1;Pd=0.6;Pv=0.1;for r=0:0.1:100if (R2>r>=0)P=0.1;plot(r,P)hold onelseif(R0>=r>=R2)P=sqrt(Pd^2-(Pd^2-Pv^2)*log(r/R0)/log(R2/R0));plot(r,P)hold onelseP=sqrt(Pd^2-(Pd^2
for r=0:0.1:100 if (R2>r>=0) %这里不能这样写,区间要写成 R2>r && r >=0
P=0.1;
plot(r,P)
hold on
elseif(R0>=r>=R2) %同样,改成 R0>r && r >=R2
P=sqrt(Pd^2-(Pd^2-Pv^2)*log(r/R0)/log(R2/R0));
plot(r,P)
hold on
else
P=sqrt(Pd^2-(Pd^2-Pa^2)*log(r/R0)/log(R1/R0));
plot(r,P)
hold on
end
end