Error using stem X must be same length as Y.
Info
This question is locked. Reopen it to edit or answer.
Show older comments
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 Comments
TUAN SHARIFAH NUR FATIEHA
on 10 Apr 2023
Rik
on 12 Apr 2025
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
on 13 Apr 2025
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
on 23 Apr 2025
(Answers Dev) Restored edit
Accepted Answer
More Answers (0)
This question is locked.
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!