How to Resolve Subscript Indices Error in f2matlab Conversion?

  • MATLAB
  • Thread starter cre_96
  • Start date
In summary, the speaker is having trouble using f2matlab to convert a f90 source code into MATLAB code. They tried using the command "f2matlab('filename.f90')" but received an error message stating that the subscript indices must be real positive integers or logicals. They ask for help in fixing this issue and suggest rewriting the fortran code so that i and j start from 1 instead of 0. They also mention that they haven't used f2matlab before and assumed it would reassign the calls automatically.
  • #1
cre_96
2
0
Hi!
I've got some trouble with using f2matlab.
I need to convert a f90 source code into MATLAB code.In order to do this i type on MATLAB command window:
>>f2matlab('filename.f90');
but MATLAB displays the following error:

? Subscript indices must either be real positive integers or logicals.

Error in ==> f2matlab at 130
if ~inastring_f(filestr(temp7(temp6(j)):temp7(temp6(i))),temp7(temp6(i))-temp7(temp6(j))+1)


Does anybody know how to fix it?
:cry:
 
Physics news on Phys.org
  • #2
I would think that your i (or j) goes from 0,1,2,3,...

temp6(0), temp6(1),...

Matlab doesn't reference elements at zero.

Maybe try rewriting the fortran code so that i and j go from 1,2,3,...

temp6(1), temp6(2),... =equal the old temp6(0), temp6(1),...

(I haven't used f2matlab but would have assumed that it reassigned these calls automatically (same if I ever wanted to convert C to Matlab).)
 
  • #3


Hi there,

It seems like you are facing an error while trying to convert a f90 source code into MATLAB code using f2matlab. The error message you received indicates that there is an issue with the indexing in your code.

One possible solution could be to check your code and make sure that all the indices used are either positive integers or logicals. It could also be helpful to check if there are any missing or incorrect parentheses or brackets in your code.

Additionally, you can try to run the code in a debugger to pinpoint the exact location of the error and troubleshoot from there.

If the issue persists, you can try reaching out to the developers of f2matlab for further assistance. They may have a better understanding of the error and how to resolve it.

I hope this helps. Good luck!
 

FAQ: How to Resolve Subscript Indices Error in f2matlab Conversion?

What is f2matlab and how is it used?

F2matlab is a function that converts Fortran code into MATLAB code. It is used to make it easier to transition from Fortran to MATLAB, as MATLAB is a more commonly used programming language in scientific research.

Is f2matlab compatible with all versions of Fortran and MATLAB?

F2matlab is compatible with most versions of Fortran, including FORTRAN 77 and Fortran 90/95. However, it may not be compatible with certain versions of MATLAB, so it is best to check the compatibility before using it.

What are the potential problems that can arise when using f2matlab?

Some common problems that can arise when using f2matlab include syntax errors, incorrect variable declarations, and differences in the way Fortran and MATLAB handle data types. It is important to carefully review the converted code and make necessary adjustments before running it.

Can f2matlab handle all types of Fortran code?

F2matlab is designed to handle most types of Fortran code, but there may be some cases where it is unable to convert the code accurately. It is best to test the converted code and make any necessary adjustments before using it in a research project.

Are there any alternatives to using f2matlab for converting Fortran code?

Yes, there are other tools and methods available for converting Fortran code to MATLAB, such as manual conversion or using a different converter program. It is important to research and compare different options to find the best fit for your specific needs.

Similar threads

Replies
2
Views
3K
Replies
5
Views
890
Replies
11
Views
2K
Replies
3
Views
2K
Replies
1
Views
8K
Replies
1
Views
1K
Replies
2
Views
10K
Back
Top