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?
    2 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Shawn Saunders
 le 8 Mai 2016
  
    
    
    
    
    Commenté : Shawn Saunders
 le 10 Mai 2016
            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 commentaires
Réponse acceptée
  Walter Roberson
      
      
 le 8 Mai 2016
        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),'...']);
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

