Please check my Matlab code!!!??

I have 2 set of data (crank angle and pressure). I upload into Workspace. http://www.flickr.com/photos/52175884@N08/8618031267/in/photostream The left column is the Crank Angle, the right column is the Pressure.
But I need to find the plot of Pressure vs Volume. The formula of Volume is given by http://www.flickr.com/photos/52175884@N08/8616297620/in/photostream
I need to write a code, such that the plot of Pressure and volume will shown. Please check my code. http://www.flickr.com/photos/52175884@N08/8619138098/in/photostream

5 comentarios

Tobias
Tobias el 4 de Abr. de 2013
Could you specify the error you are getting?
Jan
Jan el 4 de Abr. de 2013
It is very tedious to follow a bunch of links. Other people post their code and error messages directly by copy&paste. This would be more friendly for the readers.
J K
J K el 4 de Abr. de 2013
@Jan Simon, this is my code.
Vd=1.236699e-4 r=10 R=3
V=(Vd/(r-1))+(Vd/2)*(1+R-cos(data(:,1))-(R^2-sin(data(:,1)).^2)^0.5) plot (V(:,1), data(:,2)), xlabel('CA'),ylabel('Pressure')
Since I already have the set of data for crank angle, hence, I substitute the value of theta in Equation with data(:,1). The data(:,1) means all row, first column(left column).
But when I write in the matlab command window, it show ??? Error using ==> mpower Inputs must be a scalar and a square matrix.
How to solve? I follow the instruction by Image Analyst, but it is still showing the same error.
Jan
Jan el 4 de Abr. de 2013
Please follow the "? Help" link to learn how to format code.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 4 de Abr. de 2013

0 votos

When you square arrays, use ".^2" instead of "^2" - if you use the dot it will do an element by element squaring (each element is squared) otherwise it's a matrix multiplication which is totally different.

6 comentarios

J K
J K el 4 de Abr. de 2013
Hi, I follwed what you said, but the error still the same.
how to solve?
Matt Kindig
Matt Kindig el 4 de Abr. de 2013
You also need to use ".^0.5" instead of "^0.5".
Can you post your updated code?
J K
J K el 4 de Abr. de 2013
I load a file (E.dat). The file has 2 column, left column is Crank angle, right column is Pressure. This is my code.
load E.dat;
CA = E(:,1);
Pressure = E(:,2);
plot(CA,Pressure);
xlabel('CA (Deg)');
ylabel('Pressure (Bar)');
title('Graph of Pressure vs CA')
Vd=1.236699e-4
r=10
R=3
V=(Vd/(r-1))+(Vd/2)*(1+R-cos(CA)-(R^2-(sin(CA).^2))^0.5);
plot (V, Pressure), xlabel('Volume'),ylabel('Pressure')
The part that I don't get is the equation part.
Image Analyst
Image Analyst el 4 de Abr. de 2013
Like Matt told you:
V=(Vd/(r-1))+(Vd/2)*(1+R-cos(CA)-(R^2-(sin(CA).^2)).^0.5);
J K
J K el 5 de Abr. de 2013
Thank you.
One more thing, the unit of Pressure is given in Bar. How can I change it into kPa in the code, or the graph?
J K
J K el 5 de Abr. de 2013
I know 1 Bar = 100kPa. But how to write that?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

J K
el 4 de Abr. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by