How to create a table using fprintf, and use data from a for loop that uses stepinfo?
이전 댓글 표시
Hello, I am trying to make a table using the fprintf function. I am using data from a for loop that I have created show below in the code. Also, the data comes from another function stepinfo. I want to have the columns named: K=1 K=10 K=30 K=50, and the rows equal to the same titles that stepinfo outputs in the command window. If you are able to help it will be most appreciated!
답변 (1개)
clc, clear, close all
% OPEN LOOP
num = {1};
den = {[1 7 10 0]};
Gs = tf(num,den)
output = step(Gs);
figure(1)
stepplot(Gs)
% CLOSED LOOP
figure(2)
hold on
k = [1 10 30 50]; % Values from question 3
for ik = 1:numel(k)
num1 = {k(ik)};
den1 = {[1 7 10 k(ik)]};
Gcl = tf(num1,den1);
output1 = step(Gcl);
INFO(ik) = stepinfo(Gcl);
stepplot(Gcl)
end
legend('K=1','K=10','K=30','K=50');
fprintf(1, 'K=1 K=10 K=30 K=50')
C = [fieldnames(INFO) permute(struct2cell(INFO),[1 3 2])].';
fprintf(1, ['%-15s\t' repmat('%f\t',1,numel(INFO)) '\n'], C{:})
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

