error Unrecognized function or variable help me please :(!
9 次查看(过去 30 天)
显示 更早的评论
the question(the part i tried to solve):
Write a function called PlotSignal, the function will display on a graph the signal it receives.
1.1. The function inputs are:
1.1.1 signalsCell – an object of cell array type, (each pair of rows in it represents one letter, see details
At the end of the question(
1.1.2 n – the number of the signal to be displayed
1.2. The function does not return any value.
1.3. The letter n from the array of cells should be displayed on a graph according to the following detail:
1.3.1. The signal color shall be black.
as you see i have an error in my code i dont know how to load the input in the workspace i tried to do
function PlotSignal(signalsCell, n)
signalsCell=signals(2*n-1:2*n,:);
Y=cell2mat(signalsCell);
X=signals(n,:);
figure;
plot(X,Y,'k');
end
the eroor
Unrecognized function or variable 'signalsCell'.
can someone please help me ? even to write all over again the function please?
thanks !
11 个评论
回答(3 个)
Catalytic
2024-2-10
signalsCell=load('signals').signals;
PlotSignal(signalsCell, 3)
function PlotSignal(signalsCell, n)
Headings=signalsCell(:,1);
Table=cell2table(signalsCell(:,2:end)');
plot(Table, 2*n-1,2*n,Color='k');
xlabel(Headings{2*n-1});
ylabel(Headings{2*n});
end
0 个评论
Stephen23
2024-2-10
编辑:Stephen23
2024-2-10
That really is very bad data design: one single numeric array would be much better than storing lots of numeric scalars in a huge cell array. Your tutor tried to replicate something like a TABLE... but should just use a TABLE. You will have to unlearn half of what they show you :(
signals = load('signals.mat').signals
PlotSignal(signals,1)
PlotSignal(signals,3)
function PlotSignal(inp,n)
sig = "y"+n;
idx = find(strcmpi(sig,inp(:,1)));
X = cell2mat(inp(idx-1,2:end));
Y = cell2mat(inp(idx-0,2:end));
plot(X,Y,'+-k');
legend(sig)
end
11 个评论
Voss
2024-2-13
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!