Hey,
I have a 10x10 matrix and two 1x10 vectors.
vector 1: [0 200 300 400 500 600 700 800 900 1000]
Vector 2 [0 2000 3000 4000 5000 6000 7000 8000 9000 10000]
Vectors are simulink inputs and the matrix is the simulink output. For example: when vector 1 is 0 and vector 2 is 2000 I get 3.1793. Below is the matrix
I am trying to create a 2d contour plot but I get straight lines. I have tried ndgrid, meshgrid, griddata etc. It did not help.
Please help!
Thanks,

 채택된 답변

Star Strider
Star Strider 2021년 5월 28일

0 개 추천

It would help to have the matrix.
Try something like this —
figure
contour(Vector_1, Vector_2, Matrix)
.

댓글 수: 8

Feyza Boyun
Feyza Boyun 2021년 5월 28일
Thanks for your answer, I tried however I get the following
and it should look something like this
Star Strider
Star Strider 2021년 5월 28일
Something appears to be wrong with the calculation of the matrix. I have no control over that.
I will delete my Answer in a few hours.
.
Notice that the axes scales of the desired matrix are completely different than what you are getting. You need to examine why your axes scales are so different, in the millions instead of in the thousands.
Feyza Boyun
Feyza Boyun 2021년 5월 29일
Thanks for your answer Walter I tried with the same scale as the desired plot but my plot is still the same. I am guessing the problem is the simulink output. Do you have any other suggestions?
Star Strider
Star Strider 2021년 5월 29일
@Feyza Boyun What calculation is Simulink performing? I suspect that calculation is incorrect.
It would likely be easier to do the calculation in MATLAB rather than Simulink.
Feyza Boyun
Feyza Boyun 2021년 5월 29일
Simulink is performing the power output of power takeoff system over time using damping and stiffness coefficients (vector 1 and vector 2) as inputs. 10 different input combinations so 10x10 cell matrix is the output. Each cells has 1x1006 variables. I used mean() function to get average of each cell (to get the average power) and now I have 10x10 double. As the stiffness coefficient increases average power has to decrease slightly which is the case in the 10x10 matrix I attached. So the code is correct, simulink has to be correct since I only use it for educational purposes. So I am not quite sure why I keep getting that plot.
Look at the first column of your data. It is strictly increasing.
Look at the last row of your data. It is strictly decreasing.
Look at your desired plot. Are there edges that are possibly strictly increasing? Yes -- the left and right edges just might be strictly increasing. However, in your desired plot, there is no situation in which two adjacent edges are both strictly increasing. Your top and bottom both increase and then decrease (or decrease and then increase).
Therefore the data you posted cannot possibly be used to create the kind of plot you expect -- not unless you have non-uniform coordinate systems.
MATLAB does not have a bug in the plotting: your data is not of the form that would be needed to get that kind of plot.
Feyza Boyun
Feyza Boyun 2021년 5월 29일
That is correct, I see it now. Thank you all for helping me spot the issue. Cheers!

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2016b

질문:

2021년 5월 28일

댓글:

2021년 5월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by