finding the gradient of a graph between two points.

Hi I have imported some data from excell and have plotted a graph from 2 columns of data. I need to find the gradient of the graph between two points, not the gradient of the whole graph because I am using data from semiconductors which properties change as the voltage increases.
Here is my code
%%%%%%%%%%%%%%% variables %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
voltage = data (:,1);
current = data (:,2);
current_density = data (:,3);
LED_power = data (:,4);
LEDPower_density = data (:,5);
Corrected = data (:,6);
droop_model = data (:,7);
electron_charge= 1.6E-19;
boltzman_constant = 1.3806503E-23;
temperature = 300;
constant = (electron_charge / (boltzman_constant*temperature));
F = plot(voltage,current);

댓글 수: 2

Luffy
Luffy 2012년 7월 5일
편집: Luffy 2012년 7월 5일
Then between which two points do you want to calculate slope as it should vary on the basis of points u choose
between 3 and 3.5 on x axis.

댓글을 달려면 로그인하십시오.

 채택된 답변

Luffy
Luffy 2012년 7월 5일
편집: Luffy 2012년 7월 5일

0 개 추천

i=find(voltage==3); % this gives index of 3 in voltage vector to calculate corresponding current value at voltage = 3.
j=find(voltage==3.5);
slope = 2*(current(j)-current(i));

댓글 수: 9

Phillip Addison
Phillip Addison 2012년 7월 5일
편집: Phillip Addison 2012년 7월 5일
when i put in this code it says that the second = on the slope = current (j) line is invalid .
??? Error: File: analysis_of_data.m Line: 29 Column: 40 The expression to the left of the equals sign is not a valid target for an assignment.
Yeah do not directly enter the code that i wrote.
In the last line just enter this ,
slope = 2*(current(j)-current(i)); %I wrote it so that u could understand
Phillip Addison
Phillip Addison 2012년 7월 5일
편집: Phillip Addison 2012년 7월 5일
it has solved the error, however the program is finding i and j as [ ] so the slope is being calculated as [ ].
Can you enter a sample of your data(to see what type it is) if this does not work
instead of i,j directly use,
current(find(voltage==3)) & current(find(voltage==3.5))
the two columns i am using are 101x1 double
i put in the line you said and it said this
ans =
Empty matrix: 0-by-1
ans =
Empty matrix: 0-by-1
Check your data,if it is a empty in between
data is all full there are no empty places
Ryan
Ryan 2012년 7월 5일
편집: Ryan 2012년 7월 5일
It looks like there are no voltage values equal to 3 or 3.5. This method relies on there being a value in voltage exactly equal to the values you set.
found my problem your answer was right.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by