フィルターのクリア

using surf for 3D plot

1 回表示 (過去 30 日間)
Ray
Ray 2015 年 10 月 7 日
回答済み: Walter Roberson 2015 年 10 月 7 日
Hello,
I am trying to plot a power against x and y positions for multiple files. The positions are the same for all the files however the power varies from one file to another. I have 3 separate mat files xpositions, positions, and power. when i load the files and try to plot i get this error "Undefined function or variable 'xpositions'.
The code is shown below:
myFolder = '/Users/redhwanmawari/Documents/MATLAB/2DimenstionalTestingGT20150907/MeasurementDataFinal/LOS0dbm15ft_finalData'; % Define your working folder
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.mat');
matFiles = dir(filePattern);
load('xpositions.mat');
load('ypositions.mat');
for k = 1:length(matFiles)
%for k = 1:1
baseFileName = matFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
matData{k} = load(fullFileName);
figure
[xpositions,ypositions] = meshgrid(xpositions,ypositions);
surf(xpositions,ypositions,rawdata.matData(k));
hold on

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 7 日
That suggests that your xpositions.mat does not have a variable named "xpositions".
Note:
[xpositions,ypositions] = meshgrid(xpositions,ypositions);
would overwrite xpositions and ypositions, which going to be a problem because you have it in a loop. Since your xpositions and ypositions do not change, meshgrid outside the loop and use the meshed variables inside the loop.

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by