Hi everyone, it has been a while since I used MATLAB, and I find myself in need of something that I hope is rather simple. I am making a surface plot of a function that is a little odd. To plot said function I would normally use meshgrid or something, but that will not work thanks to my function.(adsbygoogle = window.adsbygoogle || []).push({});

So instead I am running it through a nested for loop and I want to just store the data after each iteration into a matrix that I can plot using surf. But I cannot seem to remember how to correctly do this.

Here's my code.

I imagine I am doing something very sill here but I am not sure. I get a horzcat error at Z=[Z z]. Thanks in advance! :)Code (Text):clear

clc

Z=0;

for x=-10:.5:10;

for t=-10:.5:10;

z=Om(x, t);

Z=[Z z];

end

end

figure;

surf(Z);

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB-saving data after loops for surf plot

**Physics Forums | Science Articles, Homework Help, Discussion**