Selecting Specific Data After csvread
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So I have a csv file named 'RedBullJumpData'. And I have a Matlab script with the following lines; close all; clear;
jumpdata = csvread('RedBullJumpData.csv'); t_redbull = jumpdata(:,1); v_redbull = jumpdata(:,2); terminal_velocity = jumpdata(:,3);
N_timestamps = length(t_redbull); velocity = 9.81*t_redbull; xlimits = [0, 180]; ylimits = [0, 400];
plot(t_solution, v1); xlabel('Time (sec)', 'fontsize', 24) ylabel('Velocity (m/s)', 'fontsize', 24) grid on; xlim(xlimits); ylim(ylimits);
As can be seen I have read the csv file already into the variable 'jumpdata'. I have assigned the first column values to t_solution, the second column values to v_solution and the third column values to terminal_velocity. The issue is that I am tasked to create another two variables (I'll just call them t_solution and v_solution) for a formula. However, t_solution has to read the data from the first column in the same csv file, only starting on row 16 of the csv file (row included). And v_solution has to start on row 16 (row included) and read in the data below this row in column 2. i.e. these two variables are a subset off their corresponding variables. Can someone provide the code to this please? I have tried using csvread again and then selecting the specific matrices but this fails.
Thank you very much Edmond
0 comentarios
Respuestas (1)
Star Strider
el 7 de Feb. de 2017
You may want to consider the example in the csvread documentation Read Specific Range from CSV File.
4 comentarios
Star Strider
el 8 de Feb. de 2017
If you are absolutely certain that row 16 in your .csv file is row 16 of your data, you can simply reference it as ‘example_variable(16:end,:)’. However, the ‘More About’ section of the R2016b documentation for the csvread function mentions:
- Skip header rows or columns by specifying row and column offsets. All values in the file other than headers must be numeric.
If there are header rows or columns, the match may not be exact. You may have to open the .csv file in a text editor to be certain. It could also be that for whatever reason, you are only supposed to use the data beginning at row 16 in the file.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!