【问题标题】:Plot a 2D curve having a table in Matlab在 Matlab 中绘制具有表格的二维曲线
【发布时间】:2014-05-12 16:56:11
【问题描述】:

我想在下表中绘制现有值:

我希望得到如下图所示的曲线:

这是我的代码:

clc
clear all
close all
time=0:0.225;    %time interval in s
Er=0:0.69;     %energy interval in J
M=[1 5 25 51.2 52428.8 104857.6 209715.2];%[20Byte 100Byte 500Byte 1kByte 1MByte    2MByte]

En=0.00653;        %energy for 20Byte in mJ
T=[0.000002125 0.000010 0.000053 0.000108 0.115 0.222];             %Time for 20Byte s
for i=1:length(M)
  for j=1:length(T)
  z(i,j)=(M(i)*En)+T(j);   %#ok<SAGROW>
end
end
grid on
semilogx(z, 'bo-')
%legend('20 Byte','100 Byte','500 Byte','1 KByte','1 MByte','2 MByte')
title('Comparison ','FontSize',11)
ylabel('Energy Consumption','FontSize',11)
xlabel('Time in second','FontSize',11)
grid on
hold all

你能告诉我我应该如何实现关于表格的逻辑图

【问题讨论】:

    标签: c matlab


    【解决方案1】:

    你忘了z怎么样

    semilogy(T,M)
    

    或者如果你愿意:

    semilogy(T,M*En)
    

    或者你可能想要:

    loglog(T,M*En)
    

    从你给出的表格和图中,并不清楚水平刻度是否应该是对数的,第一部分似乎是对数的,但随后逐渐变细。

    【讨论】:

    • 根据表格给出的情节只是猜测。(T,M * En):通过编写此命令,我收到错误。
    • 是的,因为 M 的长度为 7,T 的长度为 6,所以让它们的长度相等。
    • 现在它更有意义了。但是为什么我看不到向上的凹度?因为表格的数值。
    • 是的,这完全取决于表中的内容,或者准确地说是T 和M。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-13
    相关资源
    最近更新 更多