MATLAB Answers

0

For a contour how to set the values of a matrix to zero for certain values of x-axis.

Asked by pankaj seliya on 13 Jul 2018 at 16:05
Latest activity Edited by Stephan Jung on 14 Jul 2018 at 6:52

I have a matrix and want to set its values to zero for a certain value of "x-axis" but when I try to do it, only the first column of the matrix goes to and there is no change in other columns. How to do it? I am using the code something like this:

z = rand(20,21); x = linspace(-10,10,20); y = linspace(0,20,21); z(x<0) = 0; contourf(x,y,z')

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Stephan Jung on 14 Jul 2018 at 6:52
Edited by Stephan Jung on 14 Jul 2018 at 6:52

Hi,

does this what you expect?

z = rand(20,21);
x = linspace(-10,10,20); 
y = linspace(0,20,21); 
z(x<0,:) = 0;
contourf(x,y,z')

Best regards

Stephan

  0 Comments

Sign in to comment.