Error using stem X must be same length as Y.
信息
This question is locked. 请重新打开它进行编辑或回答。
显示 更早的评论
fs = 100000; %sampling frequency
Ts = 1/fs;
Tstart = 22.7; % change to 22.6 for 2.4s time window
N = 2500001;%number of sample for fitting
T = N*Ts;
Electrical_Output_Torque = out.ScopeData12(:,2);
currenta=out.ScopeData7(:,2);
currentb=out.ScopeData7(:,3);
currentc=out.ScopeData7(:,4);
t1 = (1:length(currenta))*Ts;
figure(1)
plot(t1,currenta,'r')
title('Current Measurement in Time Domain');
xlabel('Time [s]');
ylabel('Current [A]');
grid on
currenta_sel = currenta(t1>=Tstart&t1<Tstart+T);
currenta_sel(1) = 0;
t1_sel = t1(t1>=Tstart&t1<Tstart+T);
figure(2)%selected time in current measurement (1.6s:4s)
plot(t1_sel,currenta_sel,'r')
title('Selected Time for the Current Measurement');
xlabel('Time [s]');
ylabel('Current [A]');
grid on
%%
ca_hanning = (currenta_sel .*hann(length(currenta_sel)))';
ca_hanning_fft = fftshift(fft(ca_hanning/length(ca_hanning)))';%2
caA_abs = abs(ca_hanning_fft);
caA_abs(1)= 0;
f1= (-fs/2):1/(T-Tstart):(fs/2);
figure(3);
stem(f1,caA_abs, 'r')
set(gca,'yscal','log')
grid on
title('4.6s, Hanning');
xlabel(' \it f (Hz)');
ylabel('|S(j\omega)| [A]');
xlim([0 100])
CaA_abs(1:2:end-1,:)= [];
f1(:,1:2:end-1)= [];
%%
figure(4);
stem(f1,CaA_abs, 'r')
set(gca,'yscal','log')
grid on
title('4kW motor- Hanning window');
xlabel(' \it f (Hz)');
ylabel('|S(j\omega)| (A)');
xlim([0 100])
6 个评论
TUAN SHARIFAH NUR FATIEHA
2023-4-10
Rik
2025-4-12
Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
If you used proper citations for anything you didn't write yourself, you should not be adversly affected by a plagiarism scan.
DGM
2025-4-13
I'm with Rik on this. The only people who should be catching flak for contributions from others are people lazily passing off their routine homework. Asking how to fix a simple usage error or asking for help in debugging is hardly a plagiarism issue when acknowledged transparently.
Personally, I doubt that MATLAB is anything more than a tool in your study. In that sense, is this thread any more detrimental to your ownership of your thesis than any moment you found it necessary to consult a textbook?
You probably mean the similarity score. It is unnecessary to delete the question, as you can explore other alternatives.
Alternative #1:
Citing this forum post is likely the best option, as the original concept of the code came from you. However, you have edited the question. Consider restoring it if you choose this alternative. If you have nothing to hide, be transparent.
Alternative #2:
Edit the code in your thesis by renaming some variables. This can be a tedious task.
Rena Berman
2025-4-23
(Answers Dev) Restored edit
采纳的回答
更多回答(0 个)
This question is locked.
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!