How can I multiply two matrices of difference size

3 views (last 30 days)
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.

Accepted Answer

James Tursa
James Tursa on 22 Jun 2016
Edited: James Tursa on 22 Jun 2016
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);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!