table calculation for CSV file

first picture is table data that I have to use and I already import it in MATLAB
  1. I tried readtable('CSVCWtable3') but MATLAB said Unable to find or open 'CSVCWtable3'. Check the path and filename or file permissions. how can I fix it?
  2. What code should I use to add all the valuse in column J? (denote as N)
  3. After I calculate N, I want to find percentage of each month like) 3J/N, 4J/N

4 Comments

Totally unable to read with old geezer eyes and nothing can do with an image, anyways...but
BigTotal=sum(CW2table3.Total);
PCTs=CW2table3{:,2:end}./sum(CW2table3{:,2:end});
sorry for small image. The first line is work but second line gave me an error
The end operator must be used within an array index expression.
"sorry for small image. "
So attach the table instead...with the paperclip. The expression should work as written.
Not an image, no. save the variable to a .mat file and attach that; we can do nothing with images except look at them.
But, from a sample table left in the workspace here from a previous answer we can illustrate that the syntax works...
>> tmp
tmp =
8×3 table
Mean MeanVals MeanUnits
_____________ _________ _________
{'200.80 V' } 200.8 V
{'22.613 mV'} 0.022613 mV
{'200.99 V' } 200.99 V
{'3.7514 ms'} 0.0037514 ms
{'25.886 ms'} 0.025886 ms
{'22.987 mV'} 0.022987 mV
{'147.81 mV'} 0.14781 mV
{'1.4309 mV'} 0.0014309 mV
>> tmp{:,2:end-1}./sum(tmp{:,2})
ans =
0.4995
0.0001
0.5000
0.0000
0.0001
0.0001
0.0004
0.0000
>>
Only had one numeric column left instead of multiples, but the tmp{:,2:end-1} syntax with end keywork worked to return the second column.

Sign in to comment.

Answers (1)

Jeremy Hughes
Jeremy Hughes on 25 Jan 2021
  1. I tried readtable('CSVCWtable3') but MATLAB said Unable to find or open 'CSVCWtable3'. Check the path and filename or file permissions. how can I fix it?
If the file is not in the PWD, you should supply the path and the extension.

Categories

Tags

Asked:

on 25 Jan 2021

Commented:

dpb
on 25 Jan 2021

Community Treasure Hunt

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

Start Hunting!