I do not know how to get my loop to be condensed nor does my plot for function y will display. Here is my code

% % Initial values to zero W=0; E=0; I=0; L=0; syms x for y=(-W*x.^2)/(24*E*I).*(6*L.^2-4*L*x+x.^2) Esteel=20000000; Ealuminum=10000000; Etitanium=17000000; E=input('Please choose either Esteel, Ealuminum or Etitanium'); W=input('Choose a value for W'); I=input('Please choose your value for interia'); L=input('Please enter value for length'); fprintf('\n The %g is your value for the load\n',ezplot(x,y)) break end W=0; E=0; I=0; L=0; for Q= W*L.^3/6*E*I Esteel=20000000; Ealuminum=10000000; Etitanium=17000000; E=input('Please choose either Esteel, Ealuminum or Etitanium'); W=input('Choose a value for W'); I=input('Please choose your value for interia'); break end fprintf('\n The %g is your value for the theta\n',Q);

1 commentaire

Please select all the code and press the code button, it will save us all a lot of work and you will get help faster.

Connectez-vous pour commenter.

 Réponse acceptée

You don't need those for loops and those break, just delete them and put those math expressions after the user inputs.
(There are even more error in the code but I won't point them out until you fix those mentioned)

4 commentaires

clear all
close all
% % Initial values to zero
W=0;
E=0;
I=0;
L=0;
syms x
y=(-W*x.^2)/(24*E*I).*(6*L.^2-4*L*x+x.^2);
Esteel=20000000;
Ealuminum=10000000;
Etitanium=17000000;
E=input('Please choose either Esteel, Ealuminum or Etitanium ');
W=input('Choose a value for W');
I=input('Please choose your value for interia ');
L=input('Please enter value for length ');
fprintf('\n The %g is your value for the load\n',y)
plot(x,y)
grid on
hold on
Q= W*L.^3/6*E*I
Esteel=20000000;
Ealuminum=10000000;
Etitanium=17000000;
E=input('Please choose either Esteel, Ealuminum or Etitanium ');
W=input('Choose a value for W ');
I=input('Please choose your value for interia ');
fprintf('\n The %g is your value for the theta\n',Q);
% I shortened my code
clear all
close all
% % Initial values to zero
W=0
E=0
I=0
L=0
Esteel=20000000;
Ealuminum=10000000;
Etitanium=17000000;
E=input('Please choose either Esteel, Ealuminum or Etitanium ');
W=input('Choose a value for W');
I=input('Please choose your value for interia ');
L=input('Please enter value for length ');
Q= W*L.^3/6*E*I;
fprintf('\n The %g is your value for the theta\n',Q);
y=(-W*x.^2)/(24*E*I).*(6*L.^2-4*L*x+x.^2);
plot(x,y)
grid on
hold on
good work, any more questions?
I figured this one out, did not have to use loops at all you cleared up my question for this one, can you help me with the next one?

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by