table calculation for CSV file

1 次查看(过去 30 天)
kevin Lee
kevin Lee 2021-1-25
评论: dpb 2021-1-25
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 个评论
dpb
dpb 2021-1-25
"sorry for small image. "
So attach the table instead...with the paperclip. The expression should work as written.
dpb
dpb 2021-1-25
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.

请先登录,再进行评论。

回答(1 个)

Jeremy Hughes
Jeremy Hughes 2021-1-25
  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.

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by