polyfit with cell array with non-uniform dimensions
이전 댓글 표시
I have a 10000×1 cell array. This example could clarify my format of data:
Assume 3×1 cell array of this cell array as follow
input_data =
{'[700 900]' }
{'[700 900 1050 800]'}
{'[700]' }
I used this function to convert to double:
Current_mA=cellfun(@str2num,input_data,'UniformOutput',false);
and the output was like this:
{1×2 double}
{1×4 double}
{[ 700]}
or
{[700 900] }
{[700 800 1050 950]}
{[700] }
Voltage_V =
{[3.3 3.4] }
{[2.3 2.37 2.35 2.5]}
{[1.95] }
I want to use below vector to interpolate between data in voltage_V with "polyfit" function
input_current_mA =
750
600
800
approxPoly = polyfit(Current_mA/1000, Voltage_V, size_sample_V - 1);
input_voltage_V = polyval(approxPoly, input_current_mA/1000);
size_sample_V is the number of each data in row. For expample for above Voltage_V:
size_sample_V =
2
4
1
The answer should be:
input_voltage_V =
3.325
2.446
1.95
- My first question is how to create "size_sample_V" automatically? (size of each row in cell array)
- If I convert the Current_mA & Voltage_V to array with blanks converted to NaN, how to use "polyfit" function to avoid this answer in output for:
approxPoly =
NaN NaN
3. Can I use cell array to use polyfit?
Thank you in advance for helping.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!