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
Phillip Addison
Phillip Addison 2012 年 7 月 5 日
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.
Luffy
Luffy 2012 年 7 月 5 日
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 [ ].
Luffy
Luffy 2012 年 7 月 5 日
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))
Phillip Addison
Phillip Addison 2012 年 7 月 5 日
編集済み: Phillip Addison 2012 年 7 月 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
Luffy
Luffy 2012 年 7 月 5 日
Check your data,if it is a empty in between
Phillip Addison
Phillip Addison 2012 年 7 月 5 日
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.
Phillip Addison
Phillip Addison 2012 年 7 月 5 日
found my problem your answer was right.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by