# Search results

1. ### MATLAB Problems integrating in a for loop in Matlab

Your syntax for 'for' isn't right - it should be: for C1 = 1:moments to do what you want. Writing it the way you did only executes the loop once (with C1 = 1).
2. ### MATLAB Need help creating a recursive script in matlab that can do this:

This should do it: S = sum((1:n).^2); (1:n) creates an array of integers from 1 to n the .^2 squares each element and the sum() function does what it says.
3. ### MATLAB Matlab GUI: changing multiple lines static text

Try setting all of your elements as cells (with the braces) so that you end up with a cell array of strings rather than a character array - your error may have something to do with that because with a character array, if A,B,C, etc. cannot have a different number of elements. e.g.: A={'blah...
4. ### MATLAB MATLAB tolerance question

I don't see anything wrong with the way you are doing it. If you want to reduce your two conditions to one condition, you can use absolute value like this: target = 4; % whatever target you want tol = 0.002; % whatever tolerance you want if abs(myVar(i)-target) <= tol . . . or if you'd like...
5. ### MATLAB Matlab question

How consistent is your input string? I mean, will it always be N=XX_ so that the number your interested in is always between N= and an underscore? If so, this should work: %Find the position of 'N='... NEIndex = findstr('N=',textString); %Find all of the underscores... uscoreIndex =...
6. ### MATLAB Matlab ODE problem

Oh - sorry about that. Have you tried playing with the tolerance? If you relax the default settings on RelTol and AbsTol, maybe it won't require such a small step size. Other than that I'm not really sure - that might just be the best you can do with the complexity of your system.
7. ### MATLAB Plot - Radian Scale (MATLAB)

Yes - you can set where the tick marks are on an axis: This will control where the ticks go (use whatever range you want): set(gca,'XTick',0:pi/2:3*pi/2) (Note that gca returns the handle for the current set of axes) This will control the labels for the ticks...
8. ### MATLAB Matlab ODE problem

You can specify the points for which the solution is found if you give a vector for the tspan argument. So, if you're saying that it's calculating for too many points when you use t = [0 .01], then you can just specify t = (0:.001:.01) or whatever values it is that you want there. I hope that...
9. ### MATLAB Exit function in matlab

try "return" to exit the function - hopefully that is what you are looking for.
10. ### MATLAB Matlab problen with reading from files - need help

Hmm... not sure what's going on. Here's what I did: - I saved the data you just printed out as a file called 'read.txt'. - here, I've copied and pasted from my command window: >> fid = fopen('read.txt') fid = 3 >> a = fscanf(fid,'%e') a = -9.822387897877512e-009...
11. ### MATLAB Matlab problen with reading from files - need help

Use %e to read in scientific notation. You don't need to specify the field width and with the way you are using the size argument, it will work without it.
12. ### MATLAB Fminsearch- Matlab help

Sure, you can use fminsearch to find where the function is a minimum, but it will not necessarily be a global minimum - fminsearch can get stuck in a local minimum so your answer will depend on your initial conditions. I'm not sure what information I can provide outside of MATLAB's help - I...
13. ### MATLAB Vectorizing loops in MATLAB

You can use logical indexing: R = rand(ret,len); X(R<pm) = bitcmp(X(R<pm),1); or equivalently since I don't think you need to use bitcmp, R = rand(ret,len); X(R<pm) = ~X(R<pm); That overwrites the values of X that have the same indices of the desired values of R. I'm...
14. ### MATLAB Modeling and Matlab

I may be a little rusty, but I think if you define your state as: s = [X, dX/dV, T, dT/dV], then you can use ode45 (or any other MATLAB ode solver). (I'm assuming you've used the solvers before and you're just having trouble with this problem.) So your derivative function will look something...
15. ### LaTeX Latex Program

You can use Notepad or any other text editor to write the code. I use WinEdt becase I think it has a nice interface. It's shareware (about \$30) that you can download. Other people here might know of better options. To compile your LaTeX source, you should download MikTex (just look it up...