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 Commenti

Luffy
Luffy il 5 Lug 2012
Modificato: Luffy il 5 Lug 2012
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.

Accedi per commentare.

 Risposta accettata

Luffy
Luffy il 5 Lug 2012
Modificato: Luffy il 5 Lug 2012
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 Commenti

Phillip Addison
Phillip Addison il 5 Lug 2012
Modificato: Phillip Addison il 5 Lug 2012
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 il 5 Lug 2012
Modificato: Phillip Addison il 5 Lug 2012
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 il 5 Lug 2012
Modificato: Ryan il 5 Lug 2012
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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by