About Table Comparing in matlab code

1 回表示 (過去 30 日間)
Adil Sardar
Adil Sardar 2020 年 10 月 5 日
編集済み: Adil Sardar 2020 年 10 月 14 日
  1 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 10 月 6 日
It's actually much more helpful if you attach your data using the paperclip icon. Your also more likely to get responses, as people are generally unwilling to transcribe data from an image to work on your question.
Also, what do you mean by get the percentage of test_data? Can you provide an example of what the expected output is for even one of of your input values?
Share what code you have tried as well. That helps us see what it is you are trying to do sometimes better than words alone.

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 10 月 8 日
編集済み: Cris LaPierre 2020 年 10 月 8 日
I would use the discretize function, using your comp data to set the edges (col 1) as well as the new values (col 2).
Here's some code. Be sure to read the linked documentation page to understand how discretize works. Most of my code just ensures the formatting is preserved when loading the data.
% Read comparison data as a table (Sheet 1)
comp = readtable('Data.xlsx','Sheet',1);
% Read test data as a timetable (Sheet 2)
opts = detectImportOptions("Data.xlsx","Sheet",2);
opts.VariableNames = ["Time", "Voltage"];
opts = setvartype(opts,["duration","double"]);
opts = setvaropts(opts,"Time","InputFormat",'hh:mm:ss.SSS');
test = readtimetable('Data.xlsx',opts,"Sheet",2);
% Bin edges must be in ascending order for discretize
comp = sortrows(comp,"OCV","ascend");
% Need one more edge than values, so added 0, since your values appear to apply to the range below it
test.Percent = discretize(test.Voltage,[0;comp.OCV],comp.SOC)
test = 10267x2 timetable
Time Voltage Percent ____________ _______ _______ 00:00:00.000 3.1005 50 00:01:00.000 3.248 55 00:02:00.000 3.3265 60 00:03:00.000 3.3866 60 00:04:00.000 3.4343 65 00:05:00.000 3.4728 65 00:06:00.000 3.4976 65 00:07:00.000 3.5047 70 00:08:00.000 3.5097 70 00:09:00.000 3.515 70 00:10:00.000 3.5202 70 00:11:00.000 3.5252 70 00:12:00.000 3.5308 70 00:13:00.000 3.536 70 00:14:00.000 3.5416 70 00:15:00.000 3.5478 70

その他の回答 (1 件)

Ayush Gupta
Ayush Gupta 2020 年 10 月 8 日
The data in excel file can be read using the readmatrix function in MATLAB. The Test_data in the second sheet can be given values accordingly defined in the first sheet using the splitapply function of MATLAB. To read about the documentation of readmatrix, look here. To see some examples on how to use splitapply function, click here.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by