I created two arrays and a matrix and I'm trying to use the 'surf' function to plot but its erroring.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
this is the code I'm using and it is giving me this error: Error using surf (line 71)
Data dimensions must agree. I'm just not sure what this means or how to fix it.
Error in Lewis_Kailey_ComputerProject1_part3 (line 9)
surf(X,Y,Z)
x=[123456];
y=[1234];
[X,Y]=meshgrid(x,y);
Z = [1 2 3 4 5 6; 2 3 4 5 6 7; 3 4 5 6 7 8; 4 5 6 7 8 9];
disp(Z)
%surf plot
subplot(2,2,1)
surf(X,Y,Z)
title('part3 surf','fontsize',20)
0 Kommentare
Antworten (1)
Star Strider
am 28 Okt. 2021
Vectors need some sort of delimiters (spaces, commas, semicolons) to be defined correctly.
x=[123456]; % <— This Is The Problem
y=[1234]; % <— This Is The Problem
x=[1 2 3 4 5 6]; % <— This Is The Solution!
y=[1 2 3 4]; % <— This Is The Solution!
[X,Y]=meshgrid(x,y)
Z = [1 2 3 4 5 6; 2 3 4 5 6 7; 3 4 5 6 7 8; 4 5 6 7 8 9];
disp(Z)
%surf plot
subplot(2,2,1)
surf(X,Y,Z)
title('part3 surf','fontsize',20)
That appears to work.
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
