필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

error in build rows of matrix

조회 수: 1 (최근 30일)
mohamad khazaeezade
mohamad khazaeezade 2018년 2월 16일
마감: MATLAB Answer Bot 2021년 8월 20일
i have this code for Computing 'dim' as number of rows of 'M' : But this code gives an error:
Error using zeros Leading inputs must be numeric.
Error in Untitled3 (line 108) M=zeros(dim,9);
the code:
clc
clear all
close all
S0 =0.02;
b = 3;
Q = 29
n = 0.017
g = 9.81;
z = 0
ystart = 2
dy=0.1;
A1 = (b+z*ystart)*ystart;
P1 = b + (2*ystart*sqrt(1+z^2));
R1 = A1/P1;
T1= b+ 2*z*ystart;
D1=A1/T1;
F1 = (T1 * Q^2)/(g*(A1)^3);
Sf1 = (Q^2)*(n^2)/((R1^(4/3))*((A1)^2));
Gy1 = (1-F1)/(S0 - Sf1);
syms yc
A=(b+z*yc)*yc;
T=b+2*z*yc;
P=b+2*yc*sqrt(1+z^2);
R=A/P;
D=A/T;
eqn=(Q ^2)/g==(A^3)/(T);
y=vpasolve (eqn);
if z>0
for ii=1:6
if real(y(ii,1))>=0 , imag(y(ii,1))==0;
yc=y(ii,1);
end
end
else
for ii=1:3
if real(y(ii,1))>=0 , imag(y(ii,1))==0;
yc=y(ii,1);
end
end
end
yc;
fr = Q / (A1*sqrt(g*D1));
if fr > 1
disp('supcr')
elseif fr < 1
disp ('subcr')
elseif fr == 1
disp ('cr')
end
syms yn
An=(b+z*yn)*yn;
Tn=b+2*z*yn;
Pn=b+2*yn*sqrt(1+z^2);
Rn=An/Pn;
Dn=An/Tn;
Eq=Q==(An/n)*S0^(0.5)*(Rn)^(2/3);
yn=vpasolve(Eq,yn,1)
if yn > yc
if ystart > yn
disp ('M1')
y2=yn;
elseif ystart > yc
disp ('M2')
y2=yn;
elseif ystart < yc
disp ('M3')
y2=yc;
end
elseif yc > yn
if ystart > yc
disp ('S1')
y2=yc;
elseif ystart > yn
disp ('S2')
y2=yn;
elseif ystart < yn
disp ('S3')
y2=yn;
end
end
dim=floor((ystart-y2)/dy+1)
M=zeros(dim,9);
  댓글 수: 1
Rik
Rik 2018년 2월 17일
편집: Rik 2018년 2월 17일
As was said in the question that was deleted, you need to say what that line should do before we can give a meaningful answer. I could suggest M=zeros(max([1 dim]),9);, which would remove the error, but I can't say if that makes any sense at all for your code.
Have a read here and here. It will greatly improve your chances of getting an answer.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by