I created two arrays and a matrix and I'm trying to use the 'surf' function to plot but its erroring.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 28 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
