I am receiving an "Illegal use of the reserved keyword 'if'" in my code. It is working fine on all the previous 'if(isempty...)' and then outputing the error on the last statement. Does anyone have any advice?
조회 수: 1 (최근 30일)
이전 댓글 표시
echo off
%See notes of pg389/656 of Vibration Simulation Textbook
clf;
clear all;
inp=input('Input "1" to enter beam dimensions, "Enter" to use default...');
if (isempty(inp))
inp=0;
else
end
if inp==0
wbeam=2
tbeam=0.2
lbeam=20
E=190*10^6
density=7.83*10^-6
else
%input size of beam and material
wbeam=input('Input width of beam, default 2mm,...');
if (isempty(wbeam))
wbeam=2;
else
end
tbeam=input('Input thickness of beam, default 0.2mm,...');
if (isempty(tbeam))
tbeam=0.2;
else
end
lbeam=input('Input thickness of beam, default 20mm,...');
if (isempty(lbeam))
lbeam=20;
else
end
E=input('Input modulus of material, mN/mm^2, default stainless steel 190e6...');
if (isempty(E))
E=190*10^6
else
end
density=input('Input density of material, kg/mm^3, default stainless steel 7.83e-6...');
if (isempty(density))
density=7.83*10^-6;
else
end
end
%input number of elements
num_elements=input('Input number of elements for beam, minimum 2, default 10...');
if (isempty(num_elements))
num_elements=10;
else
end
%define whether or not to do Guyan Reduction
guyan=input('enter "1" to do Guyan elimination of rotations,..., "enter" to not do Guyan...')
if (isempty(guyan))
guyan=0;
else
end
if guyan==0
num_plot_max=2*num_elements;
num_plot_default=num_elements;
else
num_plot_max=num_elements;
num_plot_default=num_elements;
end
num_plot=input(['enter the number of modes to plot,max',...num2str(num_plot_max,',default',num2str(num_plot_default),'...']);
if (isempty(num_plot))
num_plot=9;
else
end
댓글 수: 0
채택된 답변
Walter Roberson
2016년 5월 8일
Your "..." in your num_plot is the continuation operator, everything after it is a comment.
num_plot=input(['enter the number of modes to plot,max',...
num2str(num_plot_max),',default',num2str(num_plot_default),'...']);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!