How to delete/remove last row from .txt file in a for loop?
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    mehtap agirsoy
 il 18 Apr 2021
  
    
    
    
    
    Commentato: mehtap agirsoy
 il 23 Apr 2021
            Hello all,
I need your help for my class project. I need to add a for loop  to my code and delete last row (time and displacement vectors) of the txt file for each iteration.Also, for each iteration I want to store my parameters and get plot. My aim is checking the time, is it long or enough? I've tried some codes and read previous questions but I couldn't fix my code.I'm really got stuck. If you're able to help,I'd be appreciate. Thanks
2 Commenti
  Jan
      
      
 il 20 Apr 2021
				What does "delete last row of text file" mean? Do you really want to modifiy the file?
What does this mean: "for each iteration I want to store my parameters and get plot"? A plot of what? I do not understand this also: "checking the time, is it long or enough"? How is "enough" defined?
What is the problem with your code?
By the way, source code looks like 1980 with all variables in UPPERCASE.
Risposta accettata
  Adam Danz
    
      
 il 20 Apr 2021
        - List path to all text files. See dir.
 - Read in the text file. See readtable, readmatrix, readcell,readtimetable.
 - Eliminate the last row using indexing. T(end,:)=[];
 - To store values within a loop, see preallocation, and use indexing.
 
If you get stuck, circle back in for another comment and show us what you've got.
6 Commenti
  Adam Danz
    
      
 il 23 Apr 2021
				Are you asking how to design the objective function for lsqnonlin?  There are examples in the documentation.
And here's info on passing additional values 
Or are you asking how to preallocate a loop variable for storing the model outputs?
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!