error size regarding contour plot
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I wan to plot a contour by using this code:
fileName = 'Simulation.txt';
nPitch = 202;
nTSR = 250;
%% Read in text file
fileID = fopen(fileName);
raw = textscan(fileID, '%f%f%f%f%f%f%f%f%f%f', 'Headerlines', 7);
fclose(fileID);
pitch = raw{3};
TSR = raw{7};
Cp = raw{8};
Ct = raw{8};
%% Re-arrange data
pitch = pitch(1:nPitch); % use individual values only
TSR = TSR(1:nPitch:end); % use individual values only
Cp = reshape(Cp, nPitch, nTSR, 1); % transform vector into matrix
Ct = reshape(Ct, nPitch, nTSR, 1); % transform vector into matrix
disp(pitch)
It seems number of unique value of pitch and TSR is wrong and this error appears:
Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension. Error in pitch_tsr_cp (line 23) Cp = reshape(Cp, nPitch, nTSR, 1); % transform vector into matrix
as I checked file also in excel I have 250 uniqe TSR value amd 202 pitch uniqe value.
2 Commenti
Mathieu NOE
il 31 Gen 2024
hello
it would help if you could share the data file as well
maybe you need to zip it if it's too big (limit = 5 Mb)
Risposta accettata
Mathieu NOE
il 31 Gen 2024
hello
I believe this is what you wanted to do
I don't see why you needed the reshape action
unzip('Simulation.zip');
fileName = 'Simulation.txt';
% WIND [m/s] ROT [rpm] PITCH [deg] POWER [kW] THRUST [N] TORQUE [Nm] TSR [-] CP [-] CT [-] CM [-]
% Read in text file
data = readmatrix(fileName);
pitch = (data(:,3));
TSR = (data(:,7));
Cp = (data(:,8));
Ct = (data(:,9));
figure(1),
scatter3(TSR,pitch,Cp,10,Cp,'filled')
% Interpolate the scattered data on the grid. Plot the results.
N = 100;
xd = linspace(min(TSR),max(TSR),N);
yd = linspace(min(pitch),max(pitch),N);
[xq,yq] = meshgrid(xd,yd);
zq = griddata(TSR,pitch,Cp,xq,yq);
figure(2),
contour(xq,yq,zq,'ShowText','on')
grid on
colorbar('vert')
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

