Info
This question is closed. Reopen it to edit or answer.
minor integrative trapz assistance
1 view (last 30 days)
Show older comments
I try the following:
c=3e8;
eta=zeros(1,31);
for xx=linspace(0,30,31);
x=0:xx;
if x==0
upplimit=(28e9*3.14e7)./(1+(1+x).^2);
y=(c*56e9*3.14e7*(1+x).^2)./(1+(1+x).^2);
eta(1,1)=upplimit*y;
else
eta(1,xx+1)=trapz(upplimit,y);
end
end
for which I get the error message on the second instance of the 'for' loop:
Maximum variable size allowed by the program is exceeded.
I would be appreciative of a correction.
0 Comments
Answers (1)
Walter Roberson
on 12 Mar 2014
You have
x=0:xx;
if x==0
recall that an "if" statement is satisfied only if all of the values being tested are non-zero. You are 0:xx which is a vector if xx is not 0 so x == 0 would fail in that case, falling through to the else. Which might be what you want, only be accident.
In the case that xx is 0 then x will be the scalar 0 and (28e9*3.14e7)./(1+(1+x).^2); is going to become (28e9*3.14e7)/2 . And that is to be the increment between rows, a value on the order of 36e16. Increment between rows because when you use trapz(X,Y) the first parameter, X, is the increment.
Question: if x is not 0 then you do not change y, so you repeat the same trapz() over and over again. Are you sure that is what you want?
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!