how to plot from .csv file?

6 views (last 30 days)
ramya
ramya on 16 Aug 2024
Edited: Walter Roberson on 16 Aug 2024
i hv to find percentage difference values for columns 3,6,9,12 for 2 pol HH and VV separatelyand find out difference at each frequency
later at x axis frequency and y axis these indivdual percentage values has to be plotted in bar chart
A=csvread('baseline.csv',1,0)
Error using dlmread (line 144)
Unable to parse a "Numeric" field when reading row 2, field 1.
Actual Text: "HH,2,1.407356125,HH,2,4.037356125,HH,2,5.037356125,HH,2,7.337356125"
Expected: A number or literal "NaN", "Inf". (possibly signed, case insensitive)

Error in csvread (line 53)
m=dlmread(filename, ',', r, c); %#ok<*DLMRD>
freq=A(1:6,2);
A_1_PE_HH=A(1:6,3);
B_2_PE_HH=A(1:6,9);
A_1_fre_HH=A(1:6,6);
B_2_fre_HH=A(1:6,12);
HH_1st_example=((A_1_PE_HH(2,1)-B_2_PE_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 6 columns
HH_2nd_example=((A_1_PE_HH(2,1)-B_2_fre_HH(2,1))A_1_PE_HH(2,1))*100 %finding percentage differnce between 3 and 12 columns
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
HH_3rd_example=((A_1_fre_HH(2,1)-B_2_PE_HH(2,1))/A_1_fre_HH(2,1))*100 %finding percentage differnce between 6 and 9 columns
HH_4th_example=((A_1_fre_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1))*100 %finding percentage differnce between 6 and 12 columns
same i have to find for VV also i m getting stuck at this place

Accepted Answer

Walter Roberson
Walter Roberson on 16 Aug 2024
Edited: Walter Roberson on 16 Aug 2024
csvread() requires that all of the fields are numeric, with the possible exception of leading rows or leading columns (provided that you pass in appropriate numeric parameters to call for the leading rows and columns to be skipped.) csvread() is completely unable to deal with text after a column that is being read, even if you set the range to exclude the text column .
Use readtable to deal with the file.

More Answers (1)

KSSV
KSSV on 16 Aug 2024
T=readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1753899/baseline.csv') ;
freq=T.(2)(1:6);
A_1_PE_HH=T.(3)(1:6) ;
B_2_PE_HH=T.(9)(1:6) ;
A_1_fre_HH=T.(6)(1:6);
B_2_fre_HH=T.(12)(1:6);
%
HH_1st_example=(A_1_PE_HH(2,1)-B_2_PE_HH(2,1))/A_1_PE_HH(2,1)*100; %finding percentage differnce between 3 and 6 columns
HH_2nd_example=(A_1_PE_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1)*100; %finding percentage differnce between 3 and 12 columns
HH_3rd_example=(A_1_fre_HH(2,1)-B_2_PE_HH(2,1))/A_1_fre_HH(2,1)*100; %finding percentage differnce between 6 and 9 columns
HH_4th_example=(A_1_fre_HH(2,1)-B_2_fre_HH(2,1))/A_1_PE_HH(2,1)*100; %finding percentage differnce between 6 and 12 columns

Categories

Find more on Printing and Saving in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!