Plot Matrix Matlab at even spaces

조회 수: 6 (최근 30일)
Matheus Nunes
Matheus Nunes 2015년 3월 27일
편집: Star Strider 2015년 3월 28일
I have a matrix A = [1000,1000] and i need to plot it at even spaces
Ex: The x axis have 1000 spaces from 1 to 1000.
The y axis have 1000 spaces from 0.5 to 500
the numbers on matrix A represent the position of each point in the z axis
For the first element of A there should be a point
(1,0.5,{1,1})
and thereafter...
(1,0.5,{1,1}) (1,1,{1,2}) (1,1.5,{1,3})...
(2,0.5,{2,1}) (2,1,{2,2}) (2,1.5,{2,3})...
(3,0.5,{3,1}) (3,1,{3,2}) (3,1.5,{3,3})...
In the end i would have a graphic containing 10^6 points
  댓글 수: 2
per isakson
per isakson 2015년 3월 27일
편집: per isakson 2015년 3월 27일
Is A a cell array?
A = [1000,1000] isn't consistent with the detailed description - or?
Matheus Nunes
Matheus Nunes 2015년 3월 27일
편집: per isakson 2015년 3월 27일
Actually i had a cell {1,1000} in which contained 1000 vectors
i transformed it in a matrix because i tought i could plot it that way...
matrixtaylor = zeros(1000,1000);
for h=1:1000
for f=1:1000
matrixtaylor(h,f) = VarTaylor{1,h}(f);
end
end

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

답변 (1개)

Star Strider
Star Strider 2015년 3월 27일
It seems that the linspace and meshgrid function will do what you want.
  댓글 수: 2
Matheus Nunes
Matheus Nunes 2015년 3월 27일
편집: per isakson 2015년 3월 27일
"Actually i had a cell {1,1000} in which contained 1000 vectors
i transformed it in a matrix because i tought i could plot it that way...
matrixtaylor = zeros(1000,1000);
for h=1:1000
for f=1:1000
matrixtaylor(h,f) = VarTaylor{1,h}(f);
end
end
i just need to plot those 1000 vectors o the z plane one next to the other spacing 0.5 from each other..."
i started using matlab recently, could you tell me how do i use meshgrid to do that? i searched and didn`t uderstand
Star Strider
Star Strider 2015년 3월 27일
편집: Star Strider 2015년 3월 28일
If I understand your ‘A’ cell array correctly, you do not need the for loops to recover your matrix from your cell array. You probably can do it with one call to cell2mat.
For example:
a = randi(10, 10, 15); % Create Numerical Array
C = mat2cell(a, ones(1,10), 15); % Convert to (10x1) Cell Of (1x15) Double Vectors
A = cell2mat(C); % Create Double Matrix A From C
I would create your x and y matrices as:
x = linspace(1, 1000, 1000);
y = linspace(0.5, 500, 1000);
[X,Y] = meshgrid(x, y);
then use surf or mesh to plot them, such as:
figure(1)
surf(X, Y, A)
grid on
If that does not match up exactly with what you want ‘A’ to be with respect to ‘X’ and ‘Y’, transpose ‘A’:
figure(1)
surf(X, Y, A.')
grid on

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

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by