You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Reproduce electric motor maps as images in Matlab Simulink
7 views (last 30 days)
Show older comments
Hello dear community,
I need your help to solve a small problem I am facing in my internship. I have a YASA 750 electric motor map that I found in a data sheet (attached) and I would like you to extract the iso-efficiency curves (torque, speed and efficiency) and reproduce them in Matlab. Is there a tool that can allow me to do this?
15 Comments
DGM
on 9 Apr 2021
There are a number of tools for transcribing graphs from images. This post lists a few.
Doing that would get you a set of x,y vectors for each curve. You could interpolate from there.
I have a feeling that trying to do this automatically via image processing is going to be a complete mess. The jpg compression is going to mess up line extraction significantly enough that the close-packed sections are going to need to be manually transcribed anyway. Trying to extract the heatmap by relying on the colorbar is similarly defeated by the gross chroma distortion in the image. Anything extracted that way would be very noisy and likely distorted in ways that are less obvious than extracting the level curves.
If it were me, I'd probably try to use one of the digitizer webapps, or I'd throw it into a vector graphics program, trace it out with bezier curves, and then export each curve as an image, import that image into Matlab, and run [x,y]=find(thiscurve) or somesuch.
Akram SLIMANI
on 9 Apr 2021
I thank you very much DGM for your reply and for the time you took to answer my question. Your answer will help me a lot and I will promptly read the post you have attached as a link.
DGM
on 9 Apr 2021
Consider the test:
I used inkscape to generate the following images by tracing over the plot with a bezier curve tool.


I can then import them into Matlab
inpict = rgb2gray(imread('curve88.png'))>127;
inpict = bwmorph(inpict,'thin',20);
[y88,x88] = find(flipud(inpict));
x88 = x88./size(inpict,2)*3250;
inpict = rgb2gray(imread('curve90.png'))>127;
inpict = bwmorph(inpict,'thin',20);
[y90,x90] = find(flipud(inpict));
x90 = x90./size(inpict,2)*3250;
clf
scatter(x88,y88,'.'); hold on;
scatter(x90,y90,'.');

Of course, this is just scattered XY data. It'll have to be interpolated somehow.
Akram SLIMANI
on 9 Apr 2021
Thank you very much for sharing this content with me. I really understood the procedure used to generate the curves. I just have to find out how to integrate my third variable which is the thermal efficiency of the engine in my map. In fact, in a map of an electric motor, for each point corresponds a torque, a speed and an associated efficiency. I would like to know if you have an idea in this sense, i.e. to integrate also the energy efficiency in my map. If not, I thank you again because I was a bit lost before you wrote your comments. It really cleared up the situation for me. Thanks a lot !!!!!!!
DGM
on 9 Apr 2021
Each of these curves is a locus of constant efficiency. The curves are the level curves of a surface whose height is efficiency. In the process of importing curves from manually extracted data, you'll end up with only x and y data. The efficiency is constant (e.g. 88% and 90% for the two curves shown). All you need is a constant vector z of the same length as x and y. If you want to try to interpolate to get a full surface, you could then concatenate the vectors for all the curves and then use griddata on them.
In case you're still working on digitizing, I went ahead and did this demo with the curves:
% find the apex of the curve
whichx = x88;
whichy = y88;
[~,idx] = min(whichx);
topmask = whichy>=whichy(idx);
% split the curve in half
xt = whichx(topmask);
yt = whichy(topmask);
xb = whichx(~topmask);
yb = whichy(~topmask);
% reduce/sort/reorient/concatenate
[xt,idx,~] = unique(xt);
yt = yt(idx);
[xb,idx,~] = unique(xb);
xb = flipud(xb);
yb = flipud(yb(idx));
x = [xb; xt];
y = [yb; yt];
% plot
plot(x,y); hold on

This will give correctly ordered vectors (as opposed to scattered data). If you're more interested in extracting the surface (as opposed to the curves themselves), sorting may not be necessary.
Akram SLIMANI
on 9 Apr 2021
Okay DGM, I clearly understood your answer. For efficiency, I will add another z vector. Thank you once again for your answers and for your precious time to help me solve my problem. I am very grateful for the effort you put into answering my question. Thank you !!!!!!!!!!
Akram SLIMANI
on 13 Apr 2021
DGM, please another question:
After generating the map, i have now a vector with 2 rows of given values of speed and torque. So what i want is to get for each value of speed and torque the corresponding efficienty. How can i do that in Matlab, please ?
DGM
on 13 Apr 2021
If you have a single curve from that plot and you've scaled the x and y data to speed and torque, then all of those speed and torque values correspond to the same efficiency.
If what you mean is to find the efficiency for points in between the curves, then you'll need to interpolate between curves. This could be done with griddata() or probably scatteredInterpolant().
Both of these methods work with scattered inputs, so like I said, they don't need the curves to be refined. Depending on how you're able to arrange things, there may be other ways. You should be able to concatenate the vectors for the curves and use either. I'm not sure how accurate these methods are going to be toward the center-right area of the plot where the slope is shallow and the curves are open. If you're looking at points between the curves, it should behave better.
Akram SLIMANI
on 14 Apr 2021
Actually, what i wanted is the following: i have the load with a given speed and torque ( a vector with 2 rows) and based on the map, i wanted to extract another vector of efficienty for every given point in Matlab using the map. I will try to use the command that you have mentionned. Thank you very much !!!!!!!!!!
Slimani Akram
on 19 Apr 2021
Please DGM, I have another question that bothered me a lot:
Actually, i have two picture: one that illustrate power as a function of time and another one speed over time. So, i have extract two excel files and what i want is to match these two files to have a picture with power versus speed. How can i do that in Matlab, please?
Slimani Akram
on 19 Apr 2021
These are the excel files that i am talking about : puissance_Z1G (time A:A, power B:B) and vitesse_Z1G (time A:A,speed B:B)
Slimani Akram
on 19 Apr 2021
I have managed to do that :
clc;
clear all;
tp=xlsread('puissance_Z1G.csv','A:A');
p=xlsread('puissance_Z1G.csv','B:B');
tv=xlsread('vitesse_Z1G.csv','A:A');
pv = interp1(tp,p, tv, 'linear', 'extrap')
plot(tp,p,'r',tv,pv,'b')
Thanks very much DGM for your openness to help many people of this large community in Matlab !!!!!!
Akram SLIMANI
on 23 Apr 2021
DGM, please i have another issue:
Now, i have two motor maps: one of the efficienty (picture_one) and another one of power (picture_two). What I want is that from only one map, i can read for any given speed and torque the corresponding efficienty and the power variation range. So my idea is to keep the picture_one and to drow the contours of the picture_three on the first one. I have tryed to use twice the function "contourf" with the a "hold on" in my code but it doesn't work because in the colorbar, i get the power values instead of the efficienty ones. So to sum up, i want a an efficienty motor map as the picture 3 and put on the curves of the picture three.
Do you have any idea how can i solve this problem ?
Pat Gipper
on 25 Apr 2021
I also see there are some community apps intended to do what you ask. I haven't looked into the one I show here but it will give you a notion that the need is recognized.
https://www.mathworks.com/matlabcentral/fileexchange/49009-image-digitizer?s_tid=srchtitle
Answers (1)
Pat Gipper
on 25 Apr 2021
A similar question was answered suggesting importing the image into Matlab and then using ginput to extract coordinates of the axes and desired curve in the picture reference coordinate system. The last step involving "correspondence matching" is a bit vague.
https://www.mathworks.com/matlabcentral/answers/95486-how-do-i-extract-x-and-y-data-from-a-printed-picture-of-a-2d-line-plot-that-i-have-scanned-and-i#answer_104839
2 Comments
Pat Gipper
on 25 Apr 2021
My pleasure. I also wanted to suggest looking into Community Apps on File Exchange. This link below might help you.
https://www.mathworks.com/matlabcentral/fileexchange/49009-image-digitizer?s_tid=srchtitle
See Also
Categories
Tags
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)