필터 지우기
필터 지우기

Combine multiple input into a single command

조회 수: 2 (최근 30일)
Slarn
Slarn 2014년 3월 8일
편집: per isakson 2014년 3월 8일
How do i combine multiple input into a single command instead of repeating the following commands
e.g. x0= 0 to 10
if true
x1=1;
delta_desired=interp1(x,y,x1);
display(delta_desired)
%Determine the stress value(N/m^2) at desired location
stress1=(delta_desired/(2*pi))*f_sigma/t;
display(stress1)
x2=2;
delta_desired2=interp1(x,y,x2);
display(delta_desired2)
%Determine the stress value(N/m^2) at desired location
stress2=(delta_desired2/(2*pi))*f_sigma/t;
display(stress2)
end
  댓글 수: 4
Slarn
Slarn 2014년 3월 8일
편집: Slarn 2014년 3월 8일
how do make it to accept from 0 to 10? seem to generate error but there will be no problem from 1:10
??? Attempted to access (0); index must be a positive integer or logical.
Error in ==> four_step_polarimetry at 123
delta_desired(i)=interp1(x,y,i);
if true
for i=0:10
delta_desired(i)=interp1(x,y,i);
end
display(delta_desired)
%Determine the stress value(N/m^2) at desired location
Stress=(delta_desired/(2*pi))*f_sigma/t;
display(Stress)
end
per isakson
per isakson 2014년 3월 8일
편집: per isakson 2014년 3월 8일
"index must be a positive integer or logical": Matlab is one-based; i.e. indices start with 1. Period! Cleve Moler once propose to add "+1".

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Stress and Strain에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by