How can I multiply two matrices of difference size

조회 수: 2 (최근 30일)
Javier Joya
Javier Joya 2016년 6월 22일
댓글: Javier Joya 2016년 6월 23일
I am trying to do some analysis from excel spreadsheets. The following information is the columns I get after importing the data into matlab. The total number of rows is 1647.
Time = data(:,1); (1647x1)
Temp_C = data(:,2); (1647x1)
dmdt = data(:,3); (1647x1)
Now, the following is what I started doing and so far, it worked well.
Temp_K = (Temp_C + 273.15); (1647x1)
dMdT = dmdt/1e6; (1647x1)
**(a) and (MM) is input information from the user >>> constant numbers
My issue is the following lines:
q = (dMdT)*(1/a); (1647x1)
w = [Temp_K/M1]; (1647x1)
v = q*(sqrt((w)));
Pressure = exp(34.146-(10830/Temp_K));
temp = (1/(Temp_K));
k_value_slope = (Pressure/v);
When I try to get the values for v, I understand since they are not the same dimension, matlab cannot perform the operation. Is there any trick or function I may use to do this? The matrix I am expecting to get for v is also a (1647x1). Also, for Pressure, I get values that are not correct. Not sure if is because Temp_K is also a vector (1647x1) and I am trying to get a (1647x1) matrix for Pressure. For (temp) I get zero values all across the board and I don't understand how can this be even possible since all I am trying to find is the reciprocal of Temp_K. Lastly, for (k_value_slope), I get a (1647x1647) matrix and again, I am expecting to a (1647x1).
I will greatly appreciate any help or feedback that may lead me in the right direction. I have tried using the "transpose, ', " function and the "reshape" but no luck thus far.

채택된 답변

James Tursa
James Tursa 2016년 6월 22일
편집: James Tursa 2016년 6월 22일
Use the "dot" version of the operators to do element-wise multiplication and division. E.g.
v = q .* (sqrt((w)));
Pressure = exp(34.146-(10830 ./ Temp_K));
temp = (1 ./ (Temp_K));
k_value_slope = (Pressure ./ v);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by