Using colormap function with area under a curve

Hi,
I would like to know how to use the colormap function. I have used the area function to find the area under the curve now I would like to show that it is changing from 1000 to 100. If I run the code below the area is only blue.
if true
X = [0.85,0.57,0.42,0.34,0.28,0.24,0.21,0.19,0.17,0.15,0.14,0.13,0.12,0.11,0.10,0.10,0.095,0.09,0.085
Y = 100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000
area(X,Y)
grid on
colormap jet
end
I am not sure if this is the correct way to do this so any help is great. Kayne

Risposte (1)

Image Analyst
Image Analyst il 22 Ago 2013
The colormap function applies a pseudocolor look up table to an image. So you'd have to create an image of that curve using interp1(), then apply the colormap.

1 Commento

I am not quite sure still how to get the image so please bare with me. I think that the variables I was using were confusing me.
I have inserted the code which I have been working from. It calculates the ideal energy from Compressed air using Isothermal process.
clc
clear all
close all
format Short eng
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define Constants
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Pf = 100:50:1000;%130*6.8947; %final in kPa 100:10:
Pi = 100;%14.7*6.8947; %final in kPa
R = 0.287; %gas constant kJ/kg.K
AT = 25; %Temperature Degrees Celcius dC
TK = 273 + AT; %Absolute temperature Degrees Kelvin K
% Isothermal Equations which are to be used
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Volumetric energy density using the ideal gas law:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
V_Isothermal = (R*TK)./Pf; % Volumetric energy density in m3/kg
Code to get colormap working
xi= 0.085526:0.041:0.85526;
yi = interp1(V_Isothermal,Pf,xi,'cubic');
plot(V_Isothermal,Pf,'o',xi,yi)
colormap jet
X = [xi;yi]'
image(X)
Which brings up only two colors Red and Blue. What I would like is the colormap to fill in from 1000 (Red) to 100 (blue) for a display.
Thanks Kayne

Accedi per commentare.

Tag

Richiesto:

il 22 Ago 2013

Community Treasure Hunt

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

Start Hunting!

Translated by