Info

This question is closed. Reopen it to edit or answer.

so for when i try to mutiply the variable v my number is really big can someone explain why. The choose in is user input

1 view (last 30 days)
what im trying to do is when the user inputs a number 0-360 depnding on the number a equation will be used but its not being multiplied by the (1/3.19e^9) for some reason everything else works
function [Deflection] = Deflection_ahdoan2(choose_in)
%DEFLECTION_AHDOAN2 Summary of this function goes here
% Detailed explanation goes here
%Deflection = ((1/3.19*10^9)*(800*first^3)-(13.68*10^6*first)-(2.5*first^4) + (2.5*second)^4 + (600*third^3);
v=(1/(3.19.*(10.^9)));
L1= 800.*((choose_in).^3) - (13.68 .* ((10.^6).*choose_in)) - (2.5).*((choose_in).^4).*v;
L2= (2.5.*((choose_in(choose_in>120)-120).^4)).*v;
L3 = (600.*((choose_in(choose_in>240)-240).^3)).*v;
Deflection = L1;
if any(choose_in>120)
Deflection(choose_in>120)=(Deflection(choose_in>120)+L2);
end
if any(choose_in>240)
Deflection(choose_in>240)=(Deflection(choose_in>240)+L3);
end

Answers (1)

John D'Errico
John D'Errico on 15 Feb 2020
I think it MAY be partly that you do not understand how to write numbers. Or, do you not understand how to write algebraic expressions? These are just guesses however, since we are not shown what your formulas should be.
That is, I see you writing numbers like
13.68*10^6
That is fine. However, it suggests you do not understand the same number can be written as
13.68e6
In another place, I see two different forms, that will yield very different results.
(1/3.19*10^9)
v=(1/(3.19.*(10.^9)));
This is suspicious, because I am not sure if you truly intended to write what you did.
Are you looking to divide the number 1 by the large number 3.19e9? Or are you looking to form the number 1/3.19, and then to multiply that result by 1e9?
Remember that 1/2*3 is NOT the number 1/6.
1/2*3
ans =
1.5
So as I said, we don't know what it is that you want to write here. But I see problems in what you have written, that suggest you are confused in how you write code. I will also guess that you need to learn how to write numbers using the scientific notation form I have shown, as that will allow you to avoid needing to multiply by large powers of 10. But all of this is just a guess, based on the ways you have written these expressions.

Tags

Community Treasure Hunt

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

Start Hunting!